server & client
-
- Posts: 267
- Joined: Fri Feb 24, 2012 9:34 am
server & client
i´m doing a little client that send text messages to a server in a remote machine.
I understand that my client code will be something as....
OpenConnection(1,"realipoftheserver",2550)
ser$=StringRequest("msg","write the msg")
count = SendData(1, ser$)
and the server
CreateServer(1,2550)
function p_....
but, the problem is that i cannot connect to the server, ever hve this error, i try to change ports and turn off the firewall.
Error in line 43 (client.hws): The following network error occurred:
connection refused
someone have any idea about how to solve this problem?
I understand that my client code will be something as....
OpenConnection(1,"realipoftheserver",2550)
ser$=StringRequest("msg","write the msg")
count = SendData(1, ser$)
and the server
CreateServer(1,2550)
function p_....
but, the problem is that i cannot connect to the server, ever hve this error, i try to change ports and turn off the firewall.
Error in line 43 (client.hws): The following network error occurred:
connection refused
someone have any idea about how to solve this problem?
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: server & client
Can you connect to the server via telnet?
-
- Posts: 267
- Joined: Fri Feb 24, 2012 9:34 am
Re: server & client
i can connect to server via 192.168.1.x and send the text, the problem is with an ip address
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: server & client
I don't understand... what do you mean by "the problem is with an ip address"?
-
- Posts: 267
- Joined: Fri Feb 24, 2012 9:34 am
Re: server & client
ok, imagine that i have a server in a computer with the ip 90.123.183.188 and port 2550
and i have this code:
CreateServer(1,2550)
Function p_ConnectFunc(msg)
Switch(msg.action)
Case "OnConnect":
DebugPrint("Connected ")
EndSwitch
EndFunction
InstallEventHandler({OnConnect = p_ConnectFunc})
Repeat
CheckEvent
Forever
is not possible send data to this ip directly from other computer with a different ip? both computers don´t share the same net, a practical example will be (i think), i do a server and you send to me text to my server
my client is this, but i don´t can connect between them
OpenConnection(1,"90.123.183.188",2550)
ser$=StringRequest("msg","write the msg")
count = SendData(1, ser$)
and i have this code:
CreateServer(1,2550)
Function p_ConnectFunc(msg)
Switch(msg.action)
Case "OnConnect":
DebugPrint("Connected ")
EndSwitch
EndFunction
InstallEventHandler({OnConnect = p_ConnectFunc})
Repeat
CheckEvent
Forever
is not possible send data to this ip directly from other computer with a different ip? both computers don´t share the same net, a practical example will be (i think), i do a server and you send to me text to my server
my client is this, but i don´t can connect between them
OpenConnection(1,"90.123.183.188",2550)
ser$=StringRequest("msg","write the msg")
count = SendData(1, ser$)
Re: server & client
If I'm understanding you correctly, you are trying to receive a connection from a computer that is not part of your local network (not connected to the same router).
You probably need to set up "port forwarding" in your router settings so that any connection coming from the outside to your router (using your global IP address) can then be directed to your computer attached to the router (using your local IP address).
You probably need to set up "port forwarding" in your router settings so that any connection coming from the outside to your router (using your global IP address) can then be directed to your computer attached to the router (using your local IP address).
-
- Posts: 267
- Joined: Fri Feb 24, 2012 9:34 am
Re: server & client
yes, you are understanding it correctly, i open all the router ports and disconnect the firewall, but i don´t can send the data i have ever the same "timeout" error
-
- Posts: 267
- Joined: Fri Feb 24, 2012 9:34 am
Re: server & client
problem solved, thanks PEB and Andreas
-
- Posts: 267
- Joined: Fri Feb 24, 2012 9:34 am
Re: server & client
maybe i found a bug, or i don´t know how use it, check this code
Case "OnConnect":
Print("client id ",msg.serverid)
.....
this code, ever return a table, i cannot have the client id, the "msg.serverid" work fine returning the number, maybe i need use another syntax?
Case "OnConnect":
Print("client id ",msg.serverid)
.....
this code, ever return a table, i cannot have the client id, the "msg.serverid" work fine returning the number, maybe i need use another syntax?
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: server & client
I'm not exactly sure what your problem is but maybe you're looking for this?
Here we use GetLocalIP() to get the IP from a network object.
Code: Select all
Case "OnConnect":
Print("client id", GetLocalIP(msg.clientid))