i going to make socket application in c# i dont know more about socket but i have tried but fail .
now i want know some more information plz share with me.
1)my server is located in other city .
2)what type of socket i need TCP or UDP ?
3)what ip i need to use public or any other ?
4)what is port i can use aor how to configure port ?
5) and any more whatever need to do this . plz its v important for me .

i going to make socket application in c# i dont know more about socket but i have tried but fail .

Please post the code you have tried so far; this will help us identify what your problem is.

1)my server is located in other city .

That's fine, as long as the server is connected to the Internet.

2)what type of socket i need TCP or UDP ?

That depends on what the server is listening for. What software is the server running that you want to connect to?

3)what ip i need to use public or any other ?

If you don't care, you can just connect your socket; the .NET runtime library will pick a local endpoint for you. If you want to use a specific endpoint, look at Socket.Bind.

4)what is port i can use aor how to configure port ?

Socket.Bind again. If you don't call it, it will just pick a port for you on the client end. If you want to use a specific local IP but don't care about the port, specify port 0.

5) and any more whatever need to do this . plz its v important for me .

I recommend Beej's Guide to Network Programming for information on how sockets work.

Read about System.Net.Sockets.Socket for language/platform specifics.

socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            socket.Bind(new IPEndPoint(IPAddress.Parse("192.168.0.102"), 5551));
            socket.Listen(100);
            Socket acepted = socket.Accept();
 Clint:
 socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint localendpoint = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 5551);

                try
                {
                    socket.Connect(localendpoint);

                }
                catch(Exception ex)
                {
                    Console.Write(ex.ToString());
                    List<string> error = new List<string>();
                    error.Add(ex.ToString());
                    Main(args);
                }

server conected with other router . my clint applicaiton not able to find server i dont know why ?

i have tried but fail .

So tell us, what does "fail" mean here? What are you expecting to happen when you run this server and client? What actually happens when you do?

System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not respond \ r \ ncorretamente after a period of time, or established connection failed \ r \ nbecause connected host has not responded 192.168.0.102:5551

this excption error when i execute clinte app.

i have confusion with this port which i wrote .
if someone know how can i check if my port is working or unblock able to receive data ?

Check your firewall to see if port 5551 should be blocked, add an exception if needed, then try again.

If it's still broken, see if binding to localhost (127.0.0.1) works.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.