Posted: Thu Nov 28, 2002 2:56 pm
Restored from previous forum. Originally posted by andyboy_uk.
Hi there,
We are trying to put together a simple client server program using pb, the server basically listens and displays any string that the client sends to it. We are using this on a single machine.
But as soon as we send data from the client, the server crashes and says that the memory pointer specified is of NULL length,
any suggestions
The code for the server is below..
and the client is below
Thanks in advance,
Andy
Andy Driskell
andyboy_uk@http://www.com on MSN Messenger
Hi there,
We are trying to put together a simple client server program using pb, the server basically listens and displays any string that the client sends to it. We are using this on a single machine.
But as soon as we send data from the client, the server crashes and says that the memory pointer specified is of NULL length,
any suggestions
The code for the server is below..
Code: Select all
OpenConsole()
systemOn = 1
result = InitNetwork()
ClearConsole()
server = CreateNetworkServer(60001)
prt = Print("Server Created and listening")
*DataBuffer = AllocateMemory(0, 1024, 0)
While systemon = 1
result = NetworkServerEvent()
Select result
Case 0
Case 1 ; -- New client on server --
Case 2 ; -- Raw Data --
input = ReceiveNetworkData(NetworkClientID(), *DataBuffer, DataBufferLength)
Print(Chr(13) + Chr(10) + Str(*DataBuffer))
Case 3 ; -- File Recd --
Case 4 ; -- Disconnection --
Default
EndSelect
Wend
End
and the client is below
Code: Select all
OpenConsole()
systemOn = 1
result = InitNetwork()
ClearConsole()
ClientID = OpenNetworkConnection("127.0.0.1", 60001)
If clientID = 0
Print("ERROR CONNECTING")
Else
Print("Client Created and ready to send ")
Print(Chr(13) + Chr(10))
While systemOn = 1
Print("> ")
strToSend$ = Input()
SendNetworkString(clientID, strToSend$)
Wend
EndIf
End
Thanks in advance,
Andy
Andy Driskell
andyboy_uk@http://www.com on MSN Messenger