Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-23-2003, 11:39 AM
Junior Member
 
Join Date: Feb 2003
Posts: 3
Default Socket Question

Can anyone post a short socket example that connects to the local host (127.0.0.1) on port 5001? I tried the following FFish script, but I get error 10038 (Socket operation on non-socket) when I try to connect.

--------------------------------------------------------------------------

var rval = false;
var address = "127.0.0.1";
var port = 5001;
var sock = new Socket;

rval = sock.connect(address, port);

if (rval == false) {
Dialogs.msgBox("Error connecting socket: " + sock.error, "Error", 16);
return;
}

--------------------------------------------------------------------------

Any and all help is appreciated.

Thanks,
Terry
Reply With Quote
  #2 (permalink)  
Old 02-23-2003, 06:11 PM
Senior Member
 
Join Date: Jan 2001
Posts: 413
Default Re: Socket Question

A sample of socket object

SWFKit Watch: http://www.swfkit.com/samples.html
Reply With Quote
  #3 (permalink)  
Old 02-23-2003, 11:38 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: Socket Question

You should create the socket first

------------------------------------------------------------------------ --

var rval = false;
var address = "127.0.0.1";
var port = 5001;
var sock = new Socket;

sock.create();
rval = sock.connect(address, port);

if (rval == false) {
Dialogs.msgBox("Error connecting socket: " + sock.error, "Error", 16);
return;
}

------------------------------------------------------------------------ --
Reply With Quote
  #4 (permalink)  
Old 02-24-2003, 06:14 AM
Junior Member
 
Join Date: Feb 2003
Posts: 3
Default Re: Socket Question

topcmm,

I added the sock.create() call and now I get a different error. I'm getting error 10035 (Resource temporarily unavailable). This is really weird.

Thanks,
Terry
Reply With Quote
  #5 (permalink)  
Old 02-24-2003, 07:54 AM
Junior Member
 
Join Date: Feb 2003
Posts: 3
Default I'm so confused

Ok. Here's how the code looks now:

-------------------------------------------------------------------------

var ret = 0;
var s = new Socket;
var conn = true;

s.create();
conn = s.connect("127.0.0.1", 5001);

if (conn == false) {
Dialogs.msgBox("Error connecting socket: " + s.error, "Error", 16);
return;
}

var instream = new StringStream;
var outstream = new StringStream;

instream.write("This is a test");
s.send(instream, instream.length);

ret = s.receive(outstream, 1024);

if (ret == -1) {
Dialogs.msgBox("Error during receive: " + s.error, "Error", 16);
return;
}

-------------------------------------------------------------------------

Whats weird about this is that "conn" winds up being false even when the socket successfully connects, but the error is different. What's even weirder is that you can safely ignore the error 10035 and remove the "if (conn == false)" statement in the code above and everything still works fine. The problem with that is you won't catch "real" errors.

At this point, the s.send() works fine, then I get an error (10057 : the socket is not connected) when I try to receive. This seems strange because I know the server is sending a reply, so I have no idea why the socket is being reported as closed.

Any ideas?

Thanks,
Terry
Reply With Quote
  #6 (permalink)  
Old 02-25-2003, 08:16 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: Socket Question

Sorry, it's really a bug of SWFKit. Sometimes the error propety cannot catch the real error.

The connect or send method should always return a WSAEWOULDBLOCK(10035) error because they are asynchronous operations.

When the operations are done, the onConnect, onSend or onReceive events will be fired.
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:23 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.