Solved

Tcp Listen and send

Posted on 2009-07-13
7
589 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DataGridview Currency Formating? 22 52
IP Calculator 10 53
Help with solving error related to resources file 4 35
SQL syntax in VB.net 5 27
Network ports are the threads that hold network communication together. They are an essential part of networking that can be easily ignore or misunderstood, my goals is to show those who don't have a strong network foundation how network ports opera…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

930 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now