C# .NET (2.0) Code to connect to an IP Address/Port and listen for messages
- or -
Post a project like this£100(approx. $126)
- Posted:
- Proposals: 9
- Remote
- #2276623
- Expired
RPA (Robotic Process Automation), Selenium, Winium Expert,C#,Vb.NET,ASP.NET,DATA SCRAPING
Chennai
1827473616771246413126908421052702507149253823425528412559125
Description
Experience Level: Entry
Estimated project duration: 1 day or less
PC 1 runs a third party application that posts messages to a specified port on PC1. My (Windows) app runs on PC2 (on the same physical network) and needs to listen asynchronously for messages to the specified port on PC1. I have set up an aynchronous socket framework within my app whereby I create a socked using the IP Address and first available port on PC2 then binds to the IPAddress and specified port on PC1 and listens for message (see code below). This is giving me a connection error in the .Bind() command but I'm not even certain that my method of setting up the socket is correct. I could really do with some help/advice to get this working. It's all written in C# in the .NET2 framework.
public void Start()
{
// Create the new socket on which we'll be listening
// We are using the first available port on the IP address of our computer to listen for messages broadcast on the specified IP Address and port number
_socket = new Socket(IPAddress.Parse(Utils.GetMyIPAddress()).AddressFamily, SocketType.Stream, ProtocolType.Tcp);
_socket.Bind(new IPEndPoint(_ipAddress, _portNumber));
// Start listening
_socket.Listen(_backlog);
_socket.BeginAccept(this.OnConnectRequest, _socket);
}
public void Start()
{
// Create the new socket on which we'll be listening
// We are using the first available port on the IP address of our computer to listen for messages broadcast on the specified IP Address and port number
_socket = new Socket(IPAddress.Parse(Utils.GetMyIPAddress()).AddressFamily, SocketType.Stream, ProtocolType.Tcp);
_socket.Bind(new IPEndPoint(_ipAddress, _portNumber));
// Start listening
_socket.Listen(_backlog);
_socket.BeginAccept(this.OnConnectRequest, _socket);
}
Paul G.
0% (0)Projects Completed
-
Freelancers worked with
-
Projects awarded
0%
Last project
6 May 2024
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies