Solved

Tcp Listen and send

Posted on 2009-07-13
7
590 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Close tabpage of custom control 9 34
VB.NET 2008 Populate DataModel with DataTable 44 28
EF5: Question about Metadata Artifact Processing 4 15
cannot connect to sqlserver 8 29
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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