Link to home
Start Free TrialLog in
Avatar of Rama Tito
Rama TitoFlag for Malaysia

asked on

how to use winsock over internet connection

hi, i am managed to use winsock in wifi condition between to pc's by using Server n client concept.
currently i am try to develop the same concept but  using internet. could anyone help me how to develop it
Avatar of Kamaraj Subramanian
Kamaraj Subramanian
Flag of Singapore image

Avatar of Rama Tito

ASKER

Hi, I did try out that, its does work in WIFI and LAN connection. But when i am trying out using different pc's with different internet source its doesn't works. Please do advice?
 
Hi!

If it works among your local server and client, there is a firewall or someting blocking it from the Internet, are ports allowed, check this and make hole ithe gateway if it's needed, normal port 80 is alloed and some others like e-mail and maybe fpt but others are closed.
Dependence what that server will do, is it a normal web server then it needs the port 80 for this operation and custom app's needs to use some other ports but if not then you can use. But this kind of concept out from http server fould not be very useful in todays markets, it's difficult for security and install.

Matti
 I can already see the problem and all that is required is a good explanation of what is going on.  In order for two computers to speak to each other, as you are intending, they need to be able to "see" each other.  Your two end point computers are not on the same subnet (or you would not likely be having this problem).  Routers take your communications from a subnet and make them part of the internet communications (automatically translating them back to the subnet on the way back).  You are trying to use computer A to talk to computer B over the internet (I).

    I
  /  \
A     B

  Computer B cannot see computer A but it can see the internet.  Computer A cannot see computer B but it can see the internet.  This does not mean that B can indirectly see A.

  Systems that need to set up this kind of communication generally have a server (S) on the internet that both A and B can connect to.  This server can facilitate the communication from A to B and B to A.  You must keep in mind that the only communication actually happening is from A to S and B to S.

    S (on the internet)
  /  \
A     B

In order to get around the layers of complexity that you can normally find, the normal means of doing this type of communication is HTTP or HTTPS.  This gets you past most firewalls, etc.

If this was not clear enough, or I have the wrong idea about what you are attempting, let me know.
Hi thank for the information. I do understand my mistake. Is there any simple code to demo this?
Thank you.
SOLUTION
Avatar of Matti
Matti
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The difference in the coding is not in the communications.  The main difference is on the server side.  You will need to allow a user some means of selecting the other computer to connect to.  This could be through a network of friends, simple availability, or just choosing from a list.  These choices must be made by you as it is your design.  Once those choices have been made you will need to make sure the the server passes communications from A to B and B to A.  If this is a communications (chat) type client then you may pass communications from A to B, C, and D (etc...).  If it is something else then your own needs will dictate how the communication handling on the server will need to be done.

To recap: the communications are the same as any other example, it is the handling on the server side (that only you can do) that is different.
Hi Guys,

My first PC
IP Address               192.168.43.67
Subnet Mask            255.255.255.0
Default Gateway     192.168.43.1

My Second PC using router
IP Address               10.1.1.4
Subnet Mask            255.255.255.0
Default Gateway     10.1.1.254

I did switch of the firewall for both pc, How do i ping both pc's  before go further.
You don't ping both PCs.  One of them is not on, effectively, a more remote network.  Ping is not going to work.  In order to use TCP you will need to make sure the port is clear from both PCs to the server.  This is why many communications technologies use port 80 (it is generally cleared for web browser usage).  You can use any port, you just need to take the extra step to be sure it is cleared by firewalls, routers, etc.

The communications MUST initiate with the client.  Each client connects to the server.  Once the connection is established information can flow both directions.

A Contact Server
A Login (this is up to you.  The client COULD receive a token from the server that is required on future calls, etc).

At this point the server can send messages to the client or just wait to receive from the client.  Normally the client sends commands that the server responds to.  You can make it so the roles change at that point though.  The client could be waiting for commands from the server.  It is all in how you design it.

B Contact Server
B Login

Each connection should be handled in a separate thread.  This allows you to code like you are only dealing with one connection (for the most part).

Your server, as mentioned before, should be on the internet.  It is best if you have a domain name to contact.  If you need to change the location of your server it becomes easy to adapt (the client address could remain the same).
I tried to say "one of them is not on the same network" and tried to change it to "One of them is, effectively, on a more remote network".  Sorry for any confusion.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, thank you for the information. I am manage to do.