>  but can I connect to different IP addresses all with the same port

Yes.

Think of it this way (Simplified):  One local IP:Port combination (C# App)
can connect to one remote IP:Port combination (C++ App) at a time.  Since
each remote port is on a different box and therefore a different IP this
rule holds.  However, since each local connection is on the same box that is
hosting your C# App, the IPs for each connection will be the same, thus you
must vary the port.  However, you don't need to vary the ports manually
since the TCP Stack will do it for you.

Make sense?

dw

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Peter Osucha
Sent: Thursday, May 17, 2007 9:58 AM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] TCP socket Communications

Doug,

No, you have not oversimplified this.  All the embedded XP machines are
listening for my C# app on port 6001.  I haven't tried it, perhaps I
should before typing this response - but an I connect to different IP
addresses all with the same port (ie, can I connect to 5 different IP
addresses all using a port number of 6001)?

The C++ apps - as far as I can tell at this time - do not care what
range of IP addresses attempt to connect to them.  And apparently, they
all expect to see my connections on port 6001 (I tried other port
numbers and got no response).

Peter

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Doug Wilson
Sent: Thursday, May 17, 2007 12:54 PM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] TCP socket Communications

If I understand you correctly, all the embeddedXP (C++ app) boxes listen
on
the same port, 6001. Your C# app needs to establish connections with all
the
C++ apps simultaneously.

If that is correct, the IP Address and Port on the C# side of the
connection
should not matter.  Simply get a socket and connect to the remote port.
Whatever IP and Port the local socket picks up is irrelevant.  (You'd
then
have one socket for each remote machine that you need to manage, which
should be fine.)

The only reason this wouldn't work is if the C++ apps are coded to only
accept connections from a range of IPs and/or ports or if there is a
firewall in the way.

Have I oversimplified this?

dw

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Peter Osucha
Sent: Thursday, May 17, 2007 7:27 AM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] TCP socket Communications

Terry,

Thanks for the reply.  The C++ app is listening on port 6001.  When I
connect using this port, I do establish a connection (the C++ app is
setup, apparently, to send a response when a successful connection is
made on the port on which it is listening).  So no error specifically.
I do see some strange behavior sometimes (the link just seems to drop
out and I can't re-establish it without shutting down the host machine)
- but that is for another time!

Following on with your helpful comments, Terry, what do I need to do to
the host machine's app to make it similar in functionality to, say,
PCAnywhere?  That is, can I setup the host to 'look' for connections on
a range of ports so that I could establish connection from my C# app to
multiple hosts?

(I will need to rewrite the C++ app at sometime anyway - looking for how
best to plan for the rewrite).

Peter

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Terry Griffin
Sent: Thursday, May 17, 2007 9:48 AM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] TCP socket Communications

Hi Peter,
     The port number you use for your application should match the port
number used by the C++ application. The C++ app will be waiting for a
connection on a particular port number. Your app connects to a
particular
machine (using it's IP address) and the port number used by the C++ app.
It is the port number that provides the common connection between you
app
and the C++ app. You should be able to create multiple sockets for the
same port with different IP addresses. What error are you getting when
you
try to do this?

Terry Griffin
Sr. Software Engineer
ALIS Corporation
10 Technology Drive
Peabody, MA 01960 USA
[EMAIL PROTECTED]
(978) 826-1569




Peter Osucha <[EMAIL PROTECTED]>
Sent by: "Discussion of advanced .NET topics."
<ADVANCED-DOTNET@DISCUSS.DEVELOP.COM>
05/17/2007 09:40 AM
Please respond to
"Discussion of advanced .NET topics."
<ADVANCED-DOTNET@DISCUSS.DEVELOP.COM>


To
ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
cc

Subject
[ADVANCED-DOTNET] TCP socket Communications






Hello,

Perhaps my question would be better served by another list - if so, can
you kindly point me to a more appropriate place, please?

I am working on a C# app to communicate with other machines on my local
network. Each host machine is running a small C++ application (on
embeddedXP) and is waiting to be contacted and then controlled by me.
My
connections involve several NET objects - the main one being the
'Socket'
class.

I create these Socket objects currently all with the same port number.
Apparently (and obviously?), I can't create multiple socket objects that
use the same port number with different IP addresses.  So I intend to
choose from a range of port numbers to open up any Socket objects I
need.

Being new to trying to effect this type of communication, I do not know
how the port for the Socket I open in my C# app (eg, 6001) relates to
the
port that is opened on the host application (the code for which I can't
review at this time).  What else do I need to be aware of concerning the
port numbers I use with the Socket objects I create, please?

Peter

===================================
This list is hosted by DevelopMentorR  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com


---
Filter service subscribers can train this email as spam or not-spam here:
http://my.email-as.net/spamham/cgi-bin/learn.pl?messageid=DC8C8664049711DC8A
6BC09828E2B2ED

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to