Im having a problem using RecieveNetworkData on the serverside [so far] I send a string from the client via SendNetworkString and when i try to retrieve it using ReceiveNetworkData on the serverside it comes out all garbled except the last character. [basically it looks like null spaces to me or invalid chars cause its just a box lol] Im still new to pb too so this is a bit frustrating. I'm using pb4. [BTW the network client/server example in the pb4 help doc don't work either, i get the same effect]
Can anyone help me? I'm really confused.
Problem with SendNetworkString and ReceiveNetworkData
-
- User
- Posts: 22
- Joined: Wed Jan 23, 2008 6:58 am
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
-
- User
- Posts: 22
- Joined: Wed Jan 23, 2008 6:58 am
i found a way around that issue using a combination of peeks and pokes but now i have run into another problem.
my server code seems to work fine. now its this thats being a pain, it connects, sends the string but its not recieving the string thats sent back and ive checked the connectionid's over and over in both the server and client. im completely lost. --note; the code will be adapted for a dll so u might see some commented out procedurereturns.
my server code seems to work fine. now its this thats being a pain, it connects, sends the string but its not recieving the string thats sent back and ive checked the connectionid's over and over in both the server and client. im completely lost. --note; the code will be adapted for a dll so u might see some commented out procedurereturns.
Code: Select all
If InitNetwork() = 0
;ProcedureReturn "Unable to initialize the network."
EndIf
Procedure.s ReceiveNetworkString(ConnectionID.l)
Length.l = ReceiveNetworkData(ConnectionID, *Buffered, 1000)
Text$ = PeekS(*Buffered, Length)
ProcedureReturn Text$
EndProcedure
*Buffered = AllocateMemory(1000)
ConnectionID = OpenNetworkConnection("127.0.0.1", 6832)
If ConnectionID
stext.s = "regkey"
PokeS(*Buffered,stext,1000)
SendNetworkData(ConnectionID, *Buffered, 1000)
Repeat
CEvent = NetworkClientEvent(ConnectionID)
If CEvent
;do something
Select CEvent
Case 1
MessageRequester("PureBasic - Server", "Server "+Str(ConnectionID)+" has send a packet !", 0)
MessageRequester("Info", ReceiveNetworkString(ConnectionID), 0)
If Text$ = "Invalid registration key"
CloseNetworkConnection(ConnectionID)
End
EndIf
EndSelect
EndIf
Until Quit = 1
EndIf
End
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
-
- User
- Posts: 22
- Joined: Wed Jan 23, 2008 6:58 am