Solved

Tcp Listen and send

Posted on 2009-07-13
7
591 Views
Last Modified: 2012-05-07
Hello i´m trying to make a application that can communicate with a Control4 director.
They Way it works is like this.
My application connects to the Control4 director on port 5020 and send a command "enable events" wich makes the control4 unit send me any events that occurs to my local port that was oppened by the tcpclient (ex 54798) then i have tried to use a tcplistener to listen to all traffic sent by the control4unit. then if a where to send data again the localport changes. but i would like to keep listening on the same localport.
Dont know if this make sense but to simplify.
Send data to port 5020
then listen to the port autochossen by the tcpclient.
thereafter bieng able to send how many commands on port 5020 and still listen on the first autoselected port.

Any help would be helpfull.
Jonas
0
Comment
Question by:BlackWolfNo1
  • 4
  • 2
7 Comments
 
LVL 23

Expert Comment

by:Christopher Kile
ID: 24862089
Under what circumstances does the port you need to listen to change?
0
 

Author Comment

by:BlackWolfNo1
ID: 24872179
i dont know the listening port until i have sent a command to the control4 unit.
It listens to the port 5020 but when i send a command to it tcpclient autochoses a port it sends from and the control4 unti only responds to that port so when i cativate the "enabled events" that the control4 unti has it will send all events to the port wich i have sent dthe command from.

Does it make any sense?
0
 
LVL 23

Expert Comment

by:Christopher Kile
ID: 24873414
Force the TcpClient to use a port of your choice, not its choice.  I know there is a method for doing so.  I will research it.
0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 

Author Comment

by:BlackWolfNo1
ID: 24945465
I have not found how i would be able to choose port to send on from tcpclient.
Have you?
0
 
LVL 23

Expert Comment

by:Christopher Kile
ID: 24951962
Sorry for the long response, I've been out of the office for a week.  I will resume research and get back to you later today.
0
 
LVL 23

Accepted Solution

by:
Christopher Kile earned 500 total points
ID: 24952032
You need to use an IPEndPoint to define the port you intend to send and receive from.  You need to construct the IPEndPoint, then pass it as the only parameter to the TCPClient constructor.

See http://msdn.microsoft.com/en-us/library/3bsb3c8f.aspx for more details.  
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET (2008) - Refactoring Question 2 23
Write to a printer using vb.net 9 39
.NET 2008 VB and C# 6 39
Create a datatable in vb.net dynamically 1 22
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Configuring network clients can be a chore, especially if there are a large number of them or a lot of itinerant users.  DHCP dynamically manages this process, much to the relief of users and administrators alike!
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question