Why can't i connect two sockets using socket programming in python? - python-3.x

I have written code using sockets in python in two devices , one is programmed with client code(desktop) and another one is server code (laptop) both are connected over wifi , in client code i have given server ip address with port number, any thoughts on whats wrong??

Related

TCP socket communication in NodeJS

The TCP socket programming code for NodeJs given at [link][1] works fine when server and client are on the same computer.
However when I run the client and server on two separate computers connected with a single Ethernet cable to the two Ethernet ports of the two computers, the client is unable to connect to the server! The have disabled the firewall on the server which is a 64 bit Windows 10 machine. The client is a 32 bit windows 7 old machine . When I start the server it starts, but when I connect the client with the IP address of the server and correct port number, it gives ECONNREFUSED error on the client)!
I am able to ping the two computers from each other. Also a Java based simple socket client and server programs are able to communicate with each other on the connection. But the NodeJs based TCP socket program given above doesn't work across the two computers. Any idea what could be the problem.
[1]: https://www.hacksparrow.com/nodejs/tcp-socket-programming-in-node-js.html

(socket.io) How to make a server only accept one connection from a device?

I want make my server only accept one connection from a device(that means people can not open several browsers to connect my server), and I use client ip to identify connections. The question is if two devices are from the same ethernet their ip address will be the same(so they can not connect to my server the same time).
I tried to use socket.request.connection.remotePort to get the client port, but it shows different every connection even in the same browser.

Auto detection of enumerated port in C#

I have one desktop application which is communicating with another Device(Monitor) via serial to USB.
I have one communication board which is connecting both the application. It has chip from CP2100 family.
That communication board is powered up by Device(Monitor) and both the application start exchanging the data. But when I'm turn off the Device(Monitor), Port which is enumerated for desktop application is lost and when turn on the device(Monitor), port is comming back but in this case desktop application is not sending the data to Device(Monitor).
I have used serial port setting to get the current port for desktop application.
Please help me to solve this problem.
I would use this function to enumerate the COM port list and while not connected to a device, loop through the com list and try and connect. If you can connect, see if you get a response back you expect, if you do you know this is the right COM port, otherwise move onto the next COM port.
string[] serialPortNames = System.IO.Ports.SerialPort.GetPortNames();

Coordinating Client and Server side Ports (TCP/IP)

I recently started experimenting with TCP/IP in Java (question not Java specific), and I was wondering if there was a work-around to this problem: I want my Client to be able to list all available Local Network servers. This is easy when every server and client use the same port, eg. 48,000 - just cycle through every possible IP and ping any existing servers...
But what if a user already had a game open that was using port 48,000? The game would just crash with no work around. A fix would be for the server to loop and test every port between say 48,000 and 60,000, but then how would the client know which port to connect to?
I want to be able to list all available servers (like a game such as Halo does), without the user having to specify a port number.
Thanks for the help

Finding server in LAN

How to find, in python, server without having it's IP in LAN?
I assume that port will be configured in file so its doesn't have to find port. I tried to search on google but I couldn't find anything useful or that could help me with it.
The server IP will be changing because it will not run constantly on the same computer.
So basically I got app with server that is on random computer in network, and I want to find its IP from another computer.
I would be really thankful for either explanation how to do it or link that could help me to do it.
Not certain if this is what you want to do, I think you want to find the IP of a server by running some python execution on the server?
You could try :
from subprocess import call
call (["ipconfig"])
This will dump the IP config and you can parse out the IP address. This assumes a windows server. You would have to modify the call for your OS.
Updated :
Check this out : TCP Communications or UDP Communications ... it looks like what you are looking for. You will still have the mess of determining the available addresses on the network (arp -a), and testing each one - this would be your client side app. Your server side app, when it receives the right query on the TCP or UDP port, would then determine it's address (ipconfig) and return the value.

Resources