When working with threads and server sockets, the existing command NetworkServerEvent() is inadequate. It does not give you enough information as it does not allow interrogation per EventClient().
I'd like to propose a new command: Result = NetworkConnectionEvent(EventClient()).
You would pass the EventClient() to this command, and information about specific connection would be returned to you. The returned result could use the same numbering scheme returned by NetworkServerEvent(), with the exception that it could never return #PB_NetworkEvent_Connect.
I believe that this is a very important requirement. I've been testing networking extensively, and it's my belief that sever sockets in threads cannot be done correctly with PureBasic alone as it is now. I am currently using the Windows API command ioctlsocket_() to return information about a socket in a thread.
New networking command needed for Threads
- RichAlgeni
- Addict
- Posts: 935
- Joined: Wed Sep 22, 2010 1:50 am
- Location: Bradenton, FL
Re: New networking command needed for Threads
I do not have a lot of experience with sockets in multiple threads but when I tried it I got some very strange results. It seamed to me that the multiple threads could process data from the same connection because of the way NetworkServerEvent() works, which obviously was not good as each might only receive part of the data or receive data that another thread was expecting. So I am in agreement that some enhancements might be needed to make handling sockets in threads much easier. In particular you need to be able to ensure that you are processing events for a specific client within the thread.
As I have suggested in the Enhancement Requests the whole networking section needs much more detailed information in the help file.
As I have suggested in the Enhancement Requests the whole networking section needs much more detailed information in the help file.
Simon White
dCipher Computing
dCipher Computing
Re: New networking command needed for Threads
I agree, ReceiveNetworkData() should not return -1 every time it receives no data. It should always return the amount of data received 0-65535. And only -1 when a real error occurs. It would also be nice to see at least a basic set of returned error codes for it as well.
See here => http://purebasic.fr/english/viewtopic.p ... 30#p390130
See here => http://purebasic.fr/english/viewtopic.p ... 30#p390130
Its Not A Bug, Its An Undocumented Feature!
Relax Its All Just Ones And Zeros
There Is No Place Like 127.0.0.1 Except ::1
I do things TO my computer, not WITH my computer... I am a nerd.
Relax Its All Just Ones And Zeros
There Is No Place Like 127.0.0.1 Except ::1
I do things TO my computer, not WITH my computer... I am a nerd.