Solved

Tcp Listen and send

Posted on 2009-07-13
7
588 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
Comment Utility
Under what circumstances does the port you need to listen to change?
0
 

Author Comment

by:BlackWolfNo1
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:BlackWolfNo1
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Query datatable in LINQ 6 39
Retain selection in datagridview 2 22
Visual Studio installation 5 32
Tabcontrol Caption? 1 21
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

8 Experts available now in Live!

Get 1:1 Help Now