News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

connecting using winsock

Started by gelatine1, April 26, 2015, 06:09:55 AM

Previous topic - Next topic

gelatine1

Hello

I created a small server and a client program. The client tries to establish a connection with the server and then sends data to the server. Everything works fine as long as my client uses a local ip address (and also works with 192.168.0.1 or 127.0.0.1) , so i can only use this with computers who are connected to the same router.
Once I try to use my public ip address to find the server then it does not work anymore. I am not sure why this does not work with any 2 computers so can anyone help me out with this ?

the program is in attachments. To run you should first open up the server. once it is running you can change the ip address in the client assembly file if you want and then compile again. if you run the client.exe file you should normally receive a messagebox with "abcd" if everything went right.

Thanks in advance


Farabi

Hi,
By what I understood, you are using your internet IP to search for the server. As far as I also tried I cant do the same thing. You will need to register your laptop to the DNS server in order to made your computer accessible by other computer publicly. I also tried to use my IP address to directly transfer data, but it seems that IP address is not specific to my house, it was my ISP IP address, it chaged each time I reset my router, and it has a different password. The only thing you can do to made your software talked each other is by using a comercial webserver which their DNS is registered as a bridge.

I tried to use kite to made my android tablet to be a server, but none had succeed, if you found a way, let me know.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

gelatine1

Do you mean there is no other way than using a dns server to send and receive data between 2 computers over the internet ?
then where would be a good place to get this dns server to my computer ?
(I'm sorry if some of the things i say make no sense, since I am not very familiar with networking and similar (which i am trying to learn now))

dedndave


dedndave


gelatine1

thank you for that page dedndave. I tried to connect with the fast server too and the same issue occurs again. I am able to connect to the server as long as i keep using my local ip - address or 127.0.0.1. but once i tell my client to connect with the server at my public ip addres then it does not work anymore. Why is this and what exactly should i do so that i am able to make the client connect to the server through a public ip address.

Siekmanski

Check your router settings, maybe it blocks the port you are using.
Creative coders use backward thinking techniques as a strategy.

dedndave

i don't really know - this is an area i haven't played with much

but, i think your server has to follow one of several protocols
examples:
HTTP, web server
FTP, file server
P2P, peer-to-peer

mabdelouahab

Hi gelatine1
I have never worked with ws2_32.dll, I worked with MSWinsockControl (MSWINSCK.OCX)
I remember that we must Define in the server: Protocol = sckTCPProtocol , and LocalPort= N then let it Listing
Client :RemotHost="ServerName OR ServerIp"; RemotPort= N; Then we Connect
You can call on the same computer, or on a local network or on the Internet; If you want, I will make an example for you

Farabi

Quote from: gelatine1 on April 27, 2015, 05:49:36 AM
Do you mean there is no other way than using a dns server to send and receive data between 2 computers over the internet ?
then where would be a good place to get this dns server to my computer ?
(I'm sorry if some of the things i say make no sense, since I am not very familiar with networking and similar (which i am trying to learn now))

Yes there is no way, I used a free server as a bridge between my tablet and my laptop for it. There is a way by downloading pagekite, but I have not tried it, basically kite also making a bridge between your device using a server, so basically it is the same. I dont think you will found a way to do this.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

Siekmanski

Quote from: Farabi on April 28, 2015, 01:36:13 PM
Quote from: gelatine1 on April 27, 2015, 05:49:36 AM
Do you mean there is no other way than using a dns server to send and receive data between 2 computers over the internet ?
then where would be a good place to get this dns server to my computer ?
(I'm sorry if some of the things i say make no sense, since I am not very familiar with networking and similar (which i am trying to learn now))

Yes there is no way, I used a free server as a bridge between my tablet and my laptop for it. There is a way by downloading pagekite, but I have not tried it, basically kite also making a bridge between your device using a server, so basically it is the same. I dont think you will found a way to do this.

Yes there is,
Ask your provider for a static ip address.
If this is not possible but your provider offers you web space, you can upload your ip address when you start your server on your computer.
You can get your current ip address via http://checkip.dyndns.org/
Now the clients can get the ip address for your server by downloading it from your web space.
Creative coders use backward thinking techniques as a strategy.

gelatine1

Quote from: Siekmanski on April 28, 2015, 04:39:11 AM
Check your router settings, maybe it blocks the port you are using.

Yes i checked my ports and it appears that all my ports are closed. Ill try to open some of them up later when i can and ill see if the program does work then.

Siekmanski

Look for this: Port Forwarding, also called Inbound Firewall Rules.

type: cmd
type: ipconfig (or ipconfig /all)

Now you can see these settings,

   Default Gateway . . . . . . . . . : 192.168.1.1 (the ip address to access your router software)

   IPv4 Address. . . . . . . . . . . : 192.168.1.10 (the ip address to forward your port number to)

Just found an old example i wrote based on source code from a guy named Pauly (if i'm correct..)
I had to forward the port for this proggy in my router software to get the server running.

Here is a client example so we all can chat with each other now. ( i'll let the server running on my PC for a while.... )
Creative coders use backward thinking techniques as a strategy.

dedndave

i think 192.168.0.1 is used to access the router software
192.168.1.1 is the gateway

my current local IP is 192.168.1.100
but, the router may assign other values to the last byte (.104 - whatever)
it depends on how many computers are connected prior to establishing a connection

however, you can change the router settings to get a fixed value
in the past, i have used port forwarding
i set up the router so that my computer was always assigned .108

that's all local stuff (LAN) - not related to the IP that's visible outside my LAN

jj2007

Siekmanski_Chat.exe seems to work here, but I'm the only person online...