Hi, I would need a major help ..
I would like to understand how to create a client / server.
I can not figure out how to make sure that the client receives messages from the server.
I hope someone can help me, thanks ..
Client/Server help!
Re: Client/Server help!
1. Check out the documentation for CreateServer().
2. Use InstallEventHandler() to catch connections and messages from the client.
3. Use something like DebugPrint() to show you what is happening.
2. Use InstallEventHandler() to catch connections and messages from the client.
3. Use something like DebugPrint() to show you what is happening.
Re: Client/Server help!
i have a problem for send data from server to client
Re: Client/Server help!
Server
Client
My problem is that after starting the server, running the client, is displayed the correct connection, but in the client window is no option displays the text sent by the server, but if I close the server window, appears the text sent by the server before closed.
I would like to realize a constant connection to receive and send data between client and server at all times.
How can I fix?
Code: Select all
@DISPLAY {title="Server"}
CreateServer(1,2550)
Function p_ConnectFunc(msg)
Switch(msg.action)
Case "OnConnect":
NPrint("Connected client id", GetLocalIP(msg.clientid))
SendData(msg.clientid,"a te")
cliid=msg.clientid
Case "OnReceiveData":
/*data$ = ReceiveData(cliid, #RECEIVELINE)
NPrint(data$)*/
SendData(msg.id,"a te")
EndSwitch
EndFunction
InstallEventHandler({OnConnect = p_ConnectFunc, onreceivedata=p_connectfunc})
Repeat
CheckEvent
Wait(1)
Forever
Code: Select all
@DISPLAY {title="Client"}
OpenConnection(1, "192.168.1.104", 2550)
SendData(1, "Ciao")
Function p_ConnectFunc(msg)
Switch(msg.action)
Case "OnReceiveData":
data$ = ReceiveData(msg.id, #RECEIVELINE)
NPrint(data$)
EndSwitch
EndFunction
InstallEventHandler({OnReceiveData = p_ConnectFunc})
;CloseConnection(1)
Repeat
CheckEvent
Forever
I would like to realize a constant connection to receive and send data between client and server at all times.
How can I fix?
Re: Client/Server help!
You should put a carriage return ("\r") and a newline character ("\n") at the end of your send line, so the client can tell that the server's message is complete.
So if you try this. . .
SendData(msg.clientid,"a te\r\n")
. . . you will probably notice that the client recognizes the message from the server much quicker.
So if you try this. . .
SendData(msg.clientid,"a te\r\n")
. . . you will probably notice that the client recognizes the message from the server much quicker.
Re: Client/Server help!
Thank you so much, I solved now.