Referring to a question I asked on SuperUser, which is recommended to be ask on SO.
I am developing a console application that sends packet to a remote server on a specific TCP Port (55000). I only have one computer to develop and test on. Is it still possible to debug my program; i.e. when I F5 debug, I send a test packet (from localhost) to localhost which is listening.
Also, I need to open up a port for development. I follow the this instruction to open a port (55000) in Window 7.
But when I netstat, the port 55000 is not even listed (i.e. the Local Address of 0.0.0.0:55000 is not there...). I also tried restarting the computer, but persist the problem.
Yes, of course you can. Just run the server to listen on port 55000, and then connect to localhost on port 55000.
You can use 2 different sites in the IIS with different ports or you can take advanatege of 'hosts' file to assign some naming for those 2 sites
Yes, it is possible. Although keep in mind that TCP ports for request and response must be different. So, if you bind your server to some port (say 2000), then your client must send requests from different port (80 usually).
Related
I’m developing an app that connects on port 9050 through the public ip of my server. It works fine on lan but if I’m connected on a different network it fails what can I do to fix this?
first try from Command Prompt this command: telnet ip 9050
if it working means the port 9050 between your pc and the server already opened , otherwise you should check why and where the port is blocked (may be firewall in this case you need to create rule in firewall to pass ).
I don't have any code to go by and I know nothing about your network configuration, but I'll tell you what I generally do when debugging a network-enabled app. First, look at your firewall rules. This will obviously vary depending on what OS you're using but on Windows 10 application-specific permissions are located in Control Panel > System and Security > Windows Defender Firewall > Advanced Settings.
After making sure your app can get through your devices' firewall, check the router settings next. Your packets may not getting by whatever inbuilt security protocols are in place. Since your program works with LAN but not over the Internet, this is a distinct possibility. Also, depending on your network configuration, port forwarding may be necessary; if you're sending data via a public IP address, the router needs some way to know which device on the local network needs to be receiving it. Additionally, if you're trying to connect to your server from the same network you're hosting it on, make sure you use the IP loopback address, which I believe is always 127.0.0.1, or in C# IPAddress.Loopback. Public addresses often won't work when connecting to a local host.
If you're still having problems, I recommend using Wireshark. It's an advanced diagnostics tool that tells you exactly what is being sent and received over your network, and can help pinpoint otherwise hard to spot issues.
I've developed a basic console application that will work as server-client. My general workflow will be like, Server starts clients connect to server and once a client send something the server will receive it and send it to ALL clients. Currently I can do this with my codes but my question is when I send back I've tested Socket.RemoteEndPoint and I saw ports like 65xxx. Like my first client had 65020, second 65021 and so go on. I wonder why this happen since I connect with using 9001 port and listen to 9001 port on my computer. I've done a little bit research but couldn't find a solution to my question. Why do I get these port numbers when I use Socket.RemoteEndPoint? It's okay for me since I don't use firewall or anything while I'm testing to even if the clients connects from another ports it's fine by me as long as its works but what if I have a firewall and I open ONLY 9001 port? Will my client-server based programs work then?
So far as the server/firewall on that machine is concerned, what normally matters is the server port. You wouldn't normally apply any filtering based on the client's port, which as I said in a comment, will normally be an ephemeral port. Under most circumstances, client code will make no effort to specify the local port or IP address and will let the OS pick appropriate values.
The Socket class's LocalEndPoint and RemoteEndPoint use "local" and "remote" to mean "from the perspective of the machine on which this code is running", not "who initiated the connection vs who was connected to".
So on the server, LocalEndPoint will give you information about the server end of the connection and RemoteEndPoint will give you information about the client end of the connection. Irrespective of who initiated the connection.
I'm kind of a beginner at programming, so I don't know what I'm about to ask is even possible. I want to make a TCP/IP connection to a server over WAN.
Both Client and Server programs were made by me they work just fine in a LAN. I'm now trying over a WAN. I know the server IP Address and the Port he's listening from, but as a client I can't make the connection. I supposed it's because the Port is not actually open/available.
How can I make this to happen in the server side? Is there a way for me to start the server (maybe as administrator) and for it to open the Port by itself? Is this a router or Firewall issue?
If I wasn't clear enough, feel free to ask.
Cheers.
PS: Let me put it this way:
If I make the connection in a LAN, it works. I set it to the local IP Address (192.168....) and choose whatever port I want and it works just fine. Once I put my public IP provided my ISP, it doesn't. I set the firewall router to accept everything and put a new rule in windows firewall to open port 100. What changed?
Please check the following list,
Server Firewall rules to exclude the desired port
Router Firewall to exclude the desired port
Check any installed security software blocking your desired port
Last and crucial! Open router interface and configure your NAT settings so the packets running via the desired port are served to your local server IP
If everyhting is fine and your ISP is not blocking the desired port then you will have no problem.
You can also visit canyouseeme.org in order to check that server listening alright!
Kind Regards,
KB
I am building a client-server chat application.
It has both a server and a client part.
Is it possible to test the application on the same machine or do i need really need two different computer to run the application.
Yes, it is possible to test your application on same machine.
IP Address of both client and server in this case would be same. Just open different ports for client and server.
Yes, it's possible.
Start your server up and it will listen to a specific port(The server application either has defined one or you have to provide one to it).
Start the client application and make it connect to your machine (127.0.0.1) with the port number your server application listens to.
You may have to modify the application to change the IP address or port number if the program you have does not provide you command line options to specify them.
You can test on the same machine. I am doing this right now as I type this note. :)
Of course normal things you would expect apply...you can't test two listeners on the same port which are on the same interface, for example. But a client connecting to a server on the same box should work no problem.
And of course before you release you should test on different machines as well. This could expose bugs that a single box config does not.
no need, you can bind same IP and different port. they will work.
or you can install a virtual machine.
You can test on the same machine, just make sure the the client and server bind to different ports.
Yes you can test it locally. You can use the loopback address of 127.0.0.1 , your machine name or ip address to connect.
If you are selecting port numbers for your app, please make sure you understand what ports are used and reserved for other programs. For example, if you try and use port 80, you will run into conflicts with people who are running web servers.
Also, while testing locally is great, you need to make sure you understand how your app will need to be configured in different firewall applications and routers.
In my company we use small application called IPMsg, a messenger kind of tool to pass messages and file to other fellows in company, even it allows to multicast the message.
And also it lists the user name, host name and IP addresses of users.
How can it do that? There is no server present for message routing and when checked through netstat command in CMD it does not show any details like what protocol and port it is using to communicate.
There is source code also available on the same site which is in VC++. I didn't understand a line of code... (I'm a C# guy)
Can anyone explain me how it can do that?
One simple way would be to let the application listen on a certain network port, and when you start your instance of it, it tries to connect to that port on each computer on the same network. If that other computer has that port open, and answers correctly, then you have found another instance of the application.
IPMsg probably multicasts a request for all clients to report their user and host details.
A similar mechanism is used when Windows Explorer attempts to find other machines on a network. A good description of this type of multicasting discovery is described here.
IPMsg is a daemon which listens to incoming connections on a specific port which is the connection port. You can find out which port it used by using Wireshark.
Start wireshark, start listening on the interface where you have connected to LAN and then start sending any message, wireshark will show you the message on the screen with the port number also.
The application is a peer-to-peer software and doesn't require a central server software to route messages. it only has a small daemon which accepts incoming connections. This is the way Jabber Instant messaging protocol also works.
As you said it lists username, hostname and ip address of users, do you mean it pings the network and finds it? If yes, then it is actually possible to find the IP addresses of computers on the Local Network which requires you to know the subnet on which you are connected.
You can use ARP/ICMP Ping to know the hosts present on your network provided you enter the correct subnet information
Multicasting a message is also nothing special. It is a feature provided with all Networking Stacks.
If you want mutlicasting in .NET, it is allowed. Check this page on Code Project which gives a nice example