Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SelectSocket and FD_SET's in FreeBasic?
#1
Would someone be able to explain to me how to use the Winsock command SelectSocket in FreeBasic in order to determine the status (readability etc) of a previously opened socket?

All the turorials on the web for C Language use of that command involve using FD_SET's to specify sockets to be checked, but FreeBasic does not seem to like FD_SET commands so I'm presuming there's another way.

Although FB will let me DIM rdfs as FD_SET, it does not seem to accept any commands for adding descriptors to that set. Or at least, I don't know what the right commands are.

Should I be using the FD_SET 's with SelectSocket, or something else like a regular array?

Any help is appreciated, thanks.
Reply
#2
Post source, or the tutorial/sample code you use...

Or wait for someone with more knowledge on winsock to reply..
Reply
#3
Okay... the socket opens, binds, listens, and accepts a connection from the client just fine. So then I want to check the socket (s) for readibility. I get stopped at this part of the source:

Code:
DIM rdfs as FD_SET
FD_SET (s, rdfs)

FreeBasic accepts the DIM just fine, but gives an error at the next line, thinking FD_SET is an array that hasn't been dimensioned yet. The command FD_SET (fd, set) is supposed to add a file descriptor to a dimensioned FD_SET already in existence. But it doesn't seem to work in FB.

As per an example Basic Chat program I found, I also tried using an array instead:

Code:
dim rdfs(0 to 1) as long
rdfs(0)=0
rdfs(1)=s  'the socket

nret=selectsocket (s+1,rdfs(1),null,null,null)

That code is accepted, but selectsocket always returns an error (-1) even when there is very definitely incoming data to be read (recv'd) on socket S, so clearly it isn't checking the socket correctly.

I've tried numerous variations of both code examples, changing the values and variable types of the arrays, but I always get "-1" every time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)