Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Tcp Listen and send

Posted on 2009-07-13
7
Medium Priority
?
596 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 2000 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

Creating an OSPF network that automatically (dynamically) reroutes network traffic over other connections to prevent network downtime.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

926 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