Page 1 of 2
server & client
Posted: Thu Feb 11, 2016 5:41 am
by xabierpayet
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?
Re: server & client
Posted: Fri Feb 12, 2016 4:21 pm
by airsoftsoftwair
Can you connect to the server via telnet?
Re: server & client
Posted: Fri Feb 12, 2016 7:12 pm
by xabierpayet
i can connect to server via 192.168.1.x and send the text, the problem is with an ip address
Re: server & client
Posted: Sun Feb 14, 2016 11:01 am
by airsoftsoftwair
I don't understand... what do you mean by "the problem is with an ip address"?
Re: server & client
Posted: Mon Feb 15, 2016 2:47 am
by xabierpayet
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$)
Re: server & client
Posted: Mon Feb 15, 2016 5:47 am
by PEB
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).
Re: server & client
Posted: Mon Feb 15, 2016 3:43 pm
by xabierpayet
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
Re: server & client
Posted: Mon Feb 15, 2016 4:02 pm
by xabierpayet
problem solved, thanks PEB and Andreas
Re: server & client
Posted: Tue Feb 16, 2016 3:13 am
by xabierpayet
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?
Re: server & client
Posted: Wed Feb 17, 2016 6:03 pm
by airsoftsoftwair
I'm not exactly sure what your problem is but maybe you're looking for this?
Code: Select all
Case "OnConnect":
Print("client id", GetLocalIP(msg.clientid))
Here we use
GetLocalIP() to get the IP from a network object.