I have developed an application to send message via TCP client and Listener. I am using a ComboBox and ping system to test which PC is online in the network.
How can I restrict the list to only those PCs on which my messenger application is running?
I am assuming it is running on a local network...
You should build in message "types" into your app. You can then send out a broadcast "is anyone there?" message. You do this using the broadcast IP subnet address x.x.x.255.
All PCs running your app should interpret the "is anyone there?" message and respond with a "I am here" message type. Collect them and populate your combo box.
Related
Hi I created a program let's say using ABAP and I want to monitor the data sent to my serial port (COM port)
Now there are a lot of software out there that can help me monitor this transaction.
But the problem is that the software only built to monitor data send from outside the computer.
For example some device sending data through com port to your pc.
BUT when you send the data from your PC to serial port it will raise an error on PORT is already open.
The way the port monitor software works is first opening the port and the read the data send to the serial port.
The problem happens when my own custom program try to send data to serial port, where I also need to open the port first.
So in order for my program to work then I have to shutdown the serial monitor software (this way I cannot use the monitor program).
But If I turn on the monitor software, then it will open a port that will make my program to become error and cannot open a port (I cannot send any data to serial port).
If I send data using my program without opening a port then it will send nothing.
You need to use com port emulator software. Generally these programs create virtual comport for listening. You application must connect to this virtual port.
Some of these emulator programs can connect virtual port to the real port. So you can get inbound and outbound data.
VB.NET Server Does Not Receive Connection Requests from Remote Clients
A VB.NET server application does not see connection requests from another client on the network (i.e. with a different IP address). However, it does see connection requests from the client application running on the same computer as the server.
The listening socket is created with the following parameters
System.Net.Sockets.AddressFamily.InterNetwork
System.Net.Sockets.SocketType.Stream
System.Net.Sockets.ProtocolType.IP
We have experimented with the preceding without success.
The endpoint to which the listening socket is bound specifies the local IP address and a specific port number.
The wait-for-connection code is textbook asynchronous:
thelistener.Listen(10)
thelistener.BeginAccept(New System.AsyncCallback(AddressOf targetofaccept), thelistener)
If the client that attempts connection is on the same computer as the listener, then targetofaccept is run successfully. If the client that attempts connection is on some other computer on the network, then targetofaccept is not run.
The behavior occurs for any other client on the network (i.e., not just one).
Thinking that there was some firewall issue, we created VB6 servers and clients using the same addresses and ports. The VB6 server will receive connection requests regardless of the client system.
There is no other issue with communication between clients and the server, as far as we can see. The network architecture has not been modified for a number of years.
We are debugging the code as a VB.NET console application.
Any tips on how to diagnose appreciated.
Before calling Listen() you need to bind your listener socket to the address 0.0.0.0 (in .NET IPAddress.Any) so that it listens to connections from any IP address.
This can be done using the Socket.Bind() method:
Dim listenerEndpoint As New IPEndPoint(IPAddress.Any, <your port>)
thelistener.Bind(listenerEndpoint)
thelistener.Listen(10)
Thank you.
Issue WAS firewall. Fixed by finding exact location of the IDE (devenv.exe), opening "Windows Firewall" in the control panel, selecting "Allow a program or feature through firewall", selecting "Allow another program...", browsing to the exact location and selecting the executable, then ensuring "Home/Work (Private)" column is checked for that "Name".
My issue is is that my UDP client is reporting that it is connected when I have nothing on the network. I'm trying to connect to a PLC module with IP 10.10.10.10 at port 7775 from a computer port of 7777. The Connect() function from the client is working, even though there is no Ethernet or wireless connection turned on.
The core of my problem revolves around my connection code I believe
Public Sub Connect()
Try
If (plcType = 0) Then
udpClient = New UdpClient(7777)
udpClient.Client.Connect(IPAddress, port)
SendCommand("ME")
End If
Catch
MsgBox("Could not connect to the controller, please check IP address." & vbCrLf & Err.Description)
'Connect()
End Try
End Sub
If I insert a break point after the Connect() command I get extremely strange behavior. After the break point is hit if I look into udpClient.Client's properties it says it is connected, but if I leave those properties and then look at it again it will suddenly change and say it is not connected and the program will correctly read that it is not connected after that point.
This issue only appeared After I connected a second computer and attempted to run the same program on it to the same device. Neither computer can correctly talk to the device anymore, that I can understand, but I can't understand why one of my computers believes that it is talking to the device when it clearly isn't.
Thank you for any help.
Update: Any connection available will trigger this condition, only if all networks are disable or disconnected will it behave as expected. However, it is still reporting as connected when there is no device on the network of that IP.
So #CodeCaster is right saying that "UDP has no notion of being connected". UDP is a connectionless fire-and-forget protocol. When you send a datagram, you have no guarantee it will reach its destination.
Different "connect" operations that are available across a multitude of languages merely mean "ok, we'll use this socket for talking to this specific address and port". This knowledge does not translate to packets being sent over the network. It is a local thing that allows you to use send function instead of sendto.
If you want to know if there's a device on your network listening to a specific IP and UDP port, then you're going to need your own synchronizing mechanism. The protocol does not support that out of the box. So examples are:
Heartbeat. Let your remote peer send a special multicast message every 5 seconds. If you haven't received a heartbeat message in 15 seconds, assume the remote peer is down. Adjust numbers at your own discretion.
Ping-pong, or echo request - echo response. Periodically send a special datagram to the remote peer and expect a response.
Handshakes, acknowledges, retries... The more robust channel you need, the more it is going to remind TCP. This is a kind of a sign to switch protocols!
I want to create a Console Application in VB that broadcasts to all IPs on Local Area Network his own Ip.
So a Timer that broadcasts the IP of the server every second. Every client that connects, receives the IP of the Server.
Then, a client logs in to the Application and sends 2 strings to the Servers IP:
Username
Password
The server checks the validity of the 2 strings, and either allows or restricts access to the Server.
How should I proceed?
I have found TcpClient and TcpListener, but I am unable to broadcast an IP to 255.255.255.255...
Mainly, what I want to achieve, is broadcast (255.255.255.255) my Local Ip (192.168.1.1), so I would broadcast the String "192.168.1.1"
You should take a look at the UDP classes instead of the TCP classes. UDP will allow you to broadcast small messages on your LAN. One the IP address is received, then you can use TCP to connect to the server.
I have a proprietary application running in my PC that listens to a specific IP address broadcasts in the NIC I bind him to.
I did an application to generate this UDP broadcast packet but the other application doesn't 'see' this packet when I have it running on the same PC. If my application is run in other PC within the same physical network it does detect.
I tried the following configurations none of them worked:
Proprietary app bound to Local Interface main IP.
My application bound to Local Interface 2nd IP.
and
Proprietary app bound to Local Interface main IP.
My application bound to Microsoft Loopback Adapter IP.
All communication is happening per Wireshark debugging, all applications send the right packets, except the Proprietary application never 'recognizes' my application.
The platform is Windows 7, and my application was done with QT, it mainly binds to the network IP with sharedaddress and writedatagram to the broadcast address.
Thanks