473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Sockets local entrypoint

I am using a Socket object to communicate to a host over TCP/IP.
All works fine but I need to add functionality.
My computer has 2 network cards, each with its own IP address and I
want to communicate using only one of them.

I do the following:
MySocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp)
MySocket.Bind(LocalEP)
MySocket.Connect(EndPoint)
CommStream = New NetworkStream(HRDConnSocket, IO.FileAccess.ReadWrite)

.... then I read and write to/from the CommStream object.

LocalEP is an IPEndPoint object to the IP address, port 0 of one of
the network cards on my computer.
EndPoint is an IPEndPoint object to the host IP and port.

What happens is that the .Connect method connects through the proper
network card but all reads and writes occur on the other card.
I was expecting that the NetworkStream would obey what was set on the
socket but it does not seem to work like that.
If anyone can help, thanks
Nov 20 '05 #1
6 1225
Hi Roger,

Sorry, I can't answer your query - it's not my area. :-(

However, for future reference, if you make an adjustment to a query,
rather than submitting it as a new query, could you make it a response to your
original ?

It helps us. :-)

Regards,
Fergus
Nov 20 '05 #2
Dont know the exact answer to your question, but looking at your code, you
use HRDConnSocket in the New NetworkStream command.... Looking in the SDK
Docs, shouldn't it be New NetworkStream(MySocket,...)???

"Roger" <ro***********@hotmail.com> wrote in message
news:c8**************************@posting.google.c om...
I am using a Socket object to communicate to a host over TCP/IP.
All works fine but I need to add functionality.
My computer has 2 network cards, each with its own IP address and I
want to communicate using only one of them.

I do the following:
MySocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp)
MySocket.Bind(LocalEP)
MySocket.Connect(EndPoint)
CommStream = New NetworkStream(HRDConnSocket, IO.FileAccess.ReadWrite)

... then I read and write to/from the CommStream object.

LocalEP is an IPEndPoint object to the IP address, port 0 of one of
the network cards on my computer.
EndPoint is an IPEndPoint object to the host IP and port.

What happens is that the .Connect method connects through the proper
network card but all reads and writes occur on the other card.
I was expecting that the NetworkStream would obey what was set on the
socket but it does not seem to work like that.
If anyone can help, thanks

Nov 20 '05 #3
Your right (and I changed it in the post), but this is just a typo in
this posting, I renamed the socket to MySocket to make it simpler but
forgot to replace that occurrence.

"Richard Brown" <rb****@easylift.org> wrote in message news:<eK**************@TK2MSFTNGP11.phx.gbl>...
Dont know the exact answer to your question, but looking at your code, you
use HRDConnSocket in the New NetworkStream command.... Looking in the SDK
Docs, shouldn't it be New NetworkStream(MySocket,...)???

"Roger" <ro***********@hotmail.com> wrote in message
news:c8**************************@posting.google.c om...
I am using a Socket object to communicate to a host over TCP/IP.
All works fine but I need to add functionality.
My computer has 2 network cards, each with its own IP address and I
want to communicate using only one of them.

I do the following:
MySocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp)
MySocket.Bind(LocalEP)
MySocket.Connect(EndPoint)
CommStream = New NetworkStream(MySocket, IO.FileAccess.ReadWrite)

... then I read and write to/from the CommStream object.

LocalEP is an IPEndPoint object to the IP address, port 0 of one of
the network cards on my computer.
EndPoint is an IPEndPoint object to the host IP and port.

What happens is that the .Connect method connects through the proper
network card but all reads and writes occur on the other card.
I was expecting that the NetworkStream would obey what was set on the
socket but it does not seem to work like that.
If anyone can help, thanks

Nov 20 '05 #4
Sorry, that is what I thought I did.
Nov 20 '05 #5
Hmm... if anyone has a response, or if you figure it out Roger, please post
it to the newsgroup, I am definitely interested in the answer for a section
of my upcoming project.

"Roger" <ro***********@hotmail.com> wrote in message
news:c8**************************@posting.google.c om...
Sorry, that is what I thought I did.

Nov 20 '05 #6
Yes you are right, I actually have MySocket in there. It is a typo
when typing my post.
Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: 0to60 | last post by:
I have a question about socket programming in general. Exactly what happens behind the scenes when I one socket connects to a different socket in listen mode? Using the dotnet framework, I...
6
by: Laxmikant Rashinkar | last post by:
Is there any way to use a C# socket in promiscuous mode? Any sample code that shows how this is done? any assistance is much appreciated! thanks LK
4
by: 0to60 | last post by:
I have a question about socket programming in general. Exactly what happens behind the scenes when I one socket connects to a different socket in listen mode? Using the dotnet framework, I...
1
by: verge | last post by:
hello everyone! how's it going? like everyone in here im in need of some help and good friendship along the way...take a look at this: //MODIFIED SO IT DEALS WITH WINDOWS FTP USING ACTIVE...
0
by: J008 | last post by:
Just looking for some insight as to why the callback "BeginReceiveFromCallback" is not being called in my "Receive" Subroutine below (when I call BeginReceiveFrom). I am trying to read data...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.