ReceiveNetworkData() hangs + further missing things

Just starting out? Need help? Post your questions and find answers here.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

ReceiveNetworkData() hangs + further missing things

Post by Andre »

see code example + more missing/requested things on german forum:
http://www.purebasic.fr/german/viewtopi ... 19&start=6
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: ReceiveNetworkData() hangs + further missing things

Post by chris319 »

From Google Translate:
If this code is executed, the program hangs up while arriving data or a disconnect event occurs, which in itself at the client usually does so can not be queried. Either the help file is wrong or the function.

Second IPv6
The help is that you can establish a connection via TCP. This works well with IPv6? If so, how can you read out the IP or when is the last incorporated in PB? If not, when it finally arrives? IPv6 is needed. Even the old Windows XP supports IPv6 for a long time already.

Third How many programmers in all languages ​​lacks many additional "parameter" in the network functions. PB makes it a nice simple case of network objects, which is great and so easy to use for a lot simpler and faster. But things like a server would bind to a specific IP/network card really important.

4th Disconnect Event
Why there are no clients in the PB disconnect event? As far as I have the exquisite, there is the such. In any case, there is an "additional code" of PureFan and dark (player) of the do just that. When completed, the PB

5th For new and advanced networking features and parameters should be questioned soon after the community desires. So it would be safe to use as PB connection IDs own sense that you can assign them by function/command data. It's best to connect a single pointer, which then shows on their own data to the connection. Then you need not even have its own connection management for the IDs.

6th General and summary:
I am grateful for the easy-to-use network functions, but as it stands, has been made ​​since 2005 in which nothing drann. Not only did I emfinde it as strongly as you make of all this next Lib. Above all, I would be very grateful since.
moogle
Enthusiast
Enthusiast
Posts: 372
Joined: Tue Feb 14, 2006 9:27 pm
Location: London, UK

Re: ReceiveNetworkData() hangs + further missing things

Post by moogle »

Pretty much what I've been requesting for the network functions for a long time now :)
Image
Toshy
User
User
Posts: 15
Joined: Fri Feb 17, 2006 3:38 am

Re: ReceiveNetworkData() hangs + further missing things

Post by Toshy »

problem:

Code: Select all

; server

If InitNetwork() = 0
  MessageRequester("Error", "Can't initialize the network !", 0)
  End
EndIf

Port = 6832

If CreateNetworkServer(0, Port)
  
  Repeat
    
    SEvent = NetworkServerEvent()
    
    If SEvent
      
      ClientID = EventClient()
      
      Select SEvent
          
        Case #PB_NetworkEvent_Connect
          
          MessageRequester("PureBasic - Server", "A new client has connected !", 0)
          
          
      EndSelect
    EndIf
    
  Until Quit = 1 
  
  CloseNetworkServer(0)
Else
  MessageRequester("Error", "Can't create the server (port in use ?).", 0)
EndIf

End   

Code: Select all


; client
If InitNetwork() = 0
  MessageRequester("Error", "Can't initialize the network !", 0)
  End
EndIf

Port = 6832
Repeat
  ConnectionID = OpenNetworkConnection("127.0.0.1", Port)
  Delay(1000)
Until ConnectionID > 0
If ConnectionID
  *DatenPuffer = AllocateMemory(100)
  Ergebnis = ReceiveNetworkData(ConnectionID, *DatenPuffer, 10) ; without received data programm wait forever
  MessageRequester("PureBasic - Client", "", 0)
  CloseNetworkConnection(ConnectionID)
Else
  MessageRequester("PureBasic - Client", "Can't find the server (Is it launched ?).", 0)
EndIf

End
by - chris - (german forum)

Code: Select all

; client
If InitNetwork() = 0
  MessageRequester("Error", "Can't initialize the network !", 0)
  End
EndIf

Port = 6832
Repeat
  ConnectionID = OpenNetworkConnection("127.0.0.1", Port)
  Delay(1000)
Until ConnectionID > 0
If ConnectionID  
  s = ConnectionID(ConnectionID)
  arg = 1
  ioctlsocket_(s, #FIONBIO, @arg)
  *DatenPuffer = AllocateMemory(100)
  Ergebnis = ReceiveNetworkData(ConnectionID, *DatenPuffer, 10) ; without received data programm wait forever
  MessageRequester("PureBasic - Client", "Ergebnis: " + Str(Ergebnis), 0)
  CloseNetworkConnection(ConnectionID)
Else
  MessageRequester("PureBasic - Client", "Can't find the server (Is it launched ?).", 0)
EndIf

End
!! sorry, i only speak some words in english. !!
1. AMD,3 GB MB-RAM,WinXP
2. Linux-TabletPC
Inet: 7 Kbyte/s Down/7Kbyte (not MBit) Up
PB4.6x
Messenger: Trillian (yahoo, skype, MSN/Live,icq)
Toshy
User
User
Posts: 15
Joined: Fri Feb 17, 2006 3:38 am

Re: ReceiveNetworkData() hangs + further missing things

Post by Toshy »

My english ist very bad. unfortunately. google-translater helps only slightly.

how can i or we inform an speak with fred about the network lib? a lot of years no update. lots of bugs. no new functions or parameters.
ReceiveNetworkData(), ReveiveNetworkFile() an also SendNetworkData() not run (ever) right.
but i need the Networklib.

a lot of persons the german forum an in this english forum write an aks since years about error and wishes. but i find no information from the Purebasic-Team about the problems with the NetworkLib an the future.

in the german forum i write some problem about the lib an wrong informations in the help-file.

additional i notice that SendNetworkData() does not work as described in the help file an sometime blocks "forever" (till server closed).

what can i do, that fred say somehing to this things, removes the errors an upgrade some funktions?

thanks
Toshy (same name in german Forum)
!! sorry, i only speak some words in english. !!
1. AMD,3 GB MB-RAM,WinXP
2. Linux-TabletPC
Inet: 7 Kbyte/s Down/7Kbyte (not MBit) Up
PB4.6x
Messenger: Trillian (yahoo, skype, MSN/Live,icq)
auser
Enthusiast
Enthusiast
Posts: 195
Joined: Wed Sep 06, 2006 6:59 am

Re: ReceiveNetworkData() hangs + further missing things

Post by auser »

Toshy wrote:problem:
No bug. This is normal behaviour on blocking sockets. Insert the missing NetworkClientEvent() before your ReceiveNetworkData() and it should work well (because it should do the missing "select()" or "poll()" for you ;)). Don't use ReceiveNetworkData() until NetworkClientEvent() tells you it's save to read without blocking (or recv_() until your socket was found in the read list of select_()) if you use blocking sockets (which seems to be the default in PB on client function).
Post Reply