When you hit a 2031 error, to troubleshoot further I'd recommend running
Wireshark (formerly, Ethereal) to capture the TCP packets sent/received when
you run your test.
Seth
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of
edward.syrett
Sent: Friday, June 27, 2008 1:47 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] #2031: Socket Error
I'm trying to send a simple string to a Printer Server on our network. The
text is a language called ZPL which is going to our little print server box
that has a Zebra Label printer on its parallel port.
Here's my test app:
?xml version=1.0 encoding=utf-8?
mx:WindowedApplication xmlns:mx=http://www.adobe.com/2006/mxml;
layout=absolute
mx:Script
![CDATA[
import mx.controls.Alert;
private function onPrintZpl():void
{
nbs! p; var sData:String = ^XA^FWR^CI13 +
^LHLabelTop,LabelLeft +
^FWB^FO512,899^XGPPI_LAN,1,1^FS^FWR +
^FO708,045^A0,40,40^FDUnit 7^FS +
^FO659,042^A0,40,40^FDKuehne + Nagel Logistics^FS +
^FO611,042^A0,40,40^FDAppletree Road^FS +
^FO562,042^A0,40,40^F! DChipping Warden^FS +
! nbsp; n bsp; ^FO522,042^A0,40,40^FDBanbury^FS +
^FO476,042^A0,40,40^FDOxfordshire^FS +
^FO430,043^A0,40,40^FDOX17 1LL^FS +
^FO381,042^A0,40,40^FDUnited Kingdom^FS +
^BY3,3,10 +
^FO141,043^B3R,N,100,Y,N^FD9^FS +
^XZ
! nbsp;
try
{
var socket:Socket = new Socket();
//socket.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
socket.connect(10.44.180.120, 9100);
socket.writeUTF(sData); n! bsp;nbs p;
socket.flush();
socket.close();
}
catch(error:Error)
{
Alert.show(error.message);
}
}
private function onIOError(event:IOErrorEvent):void {
}
]]
/mx:Script
mx:VBox width=100% label=Printing
mx:Button label=ZPL Print click=onPrintZpl()/
/mx:VBox
/mx:WindowedApplication
With the app as it stands, I can hit the ZPL Print button, the label is
printed, but then the app throws this error:
[SWF] SocketTest.swf - 902,761 bytes after decompression
Error #2044: Unhandled IOErrorEvent:. text=Error #2031: Socket Error.
at SocketTest/onPrintZpl()[C:\Development\Monarch\Test\SocketT!
est\src\SocketTest.mxml:28]
at! SocketT
est/___SocketTest_Button1_click()[C:\Development\Monarch\Test\SocketTest\src\SocketTest.mxml:58]
If I uncomment the call to addEventListener() for IOErrorEvent.IO_ERROR, the
app runs without any errors, but the label isn't printed.
Any comments/help gratefully received.
Thanks,
Ed.