473,322 Members | 1,846 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,322 software developers and data experts.

Socket connection between multiple interfaces, through a router

Hi,

I have two ethernet interfaces on my system, with IPs assigned to the
interfaces from different subnets (e.g. eth1 - 10.10.10.10 and eth2 -
20.20.20.20 ). I'm connecting these interfaces to a home gateway or
router. The 'eth1' interface connects to LAN interface of the router
with IP address 10.10.10.1 and the 'eth2' interface connects to WAN
interface of the router with IP address 20.20.20.1.

I'm trying a simple socket program with C on Redhat Linux 9. I'm trying
to create a server socket (UDP or TCP) on my eth2 interface
(20.20.20.20), and a client socket (UDP or TCP) on my eth1 interface
(10.10.10.10). When I try to connect and send packets from eth1 to eth2
or vice-versa, the packets do not seem to pass through the router and
instead seem to create a local connection within the system. I verified
this with ethereal on both the interfaces eth1 and eth2). I wasn't
seeing any packets on these interfaces.

Just FYI, I was using AF_INET address family. I have routes
appropriately setup for the interfaces with 10.10.10.1 as the gateway
on the LAN side, and 20.20.20.1 as the gateway on the WAN side.

Why does the socket connection bypass the router? Is there a way to
ensure that my socket connection goes through the router, instead of
creating a local connection?

I'd appreciate if any one could help me with the solution to my above
problem, either with explanation or through sample code.

Thanks,
Seets.

Jul 16 '06 #1
4 4822
se******@yahoo.com writes:
Why does the socket connection bypass the router? Is there a way to
ensure that my socket connection goes through the router, instead of
creating a local connection?
Your question is outside the domain of comp.lang.c, which discusses
only the standard C programming language, including the standard C
library. This is a remarkably narrow topic compared to what many
people expect.

For your convenience, the list below contains topics that are not
on-topic for comp.lang.c, and suggests newsgroups for you to explore
if you have questions about these topics. Please do observe proper
netiquette before posting to any of these newsgroups. In particular,
you should read the group's charter and FAQ, if any (FAQs are
available from www.faqs.org and other sources). If those fail to
answer your question then you should browse through at least two weeks
of recent articles to make sure that your question has not already
been answered.

* OS-specific questions, such as how to clear the screen,
access the network, list the files in a directory, or read
"piped" output from a subprocess. These questions should be
directed to OS-specific newsgroups, such as
comp.os.ms-windows.programmer.misc, comp.unix.programmer, or
comp.os.linux.development.apps.

* Compiler-specific questions, such as installation issues,
locations of header files, configuring your C development
environment, or choosing or managing profiling tools,
debuggers, or code coverage tools. Ask about these in
compiler-specific newsgroups, such as gnu.gcc.help or
comp.os.ms-windows.programmer.misc. Questions about writing
compilers are appropriate in comp.compilers.

* Library-specific questions, such as how to use GLib, Kazlib,
libavl, libsndfile, GMP, GNU GSL, djbfft, CLAPACK, CBLAS,
libtomcrypt, etc. Ask about these in library-specific
newsgroups or mailing lists.

* Processor-specific questions, such as questions about
assembly and machine code. x86 questions are appropriate in
comp.lang.asm.x86, embedded system processor questions may
be appropriate in comp.arch.embedded.

* ABI-specific questions, such as how to interface assembly
code to C. These questions are both processor- and
OS-specific and should typically be asked in OS-specific
newsgroups.

* Algorithms, except questions about C implementations of
algorithms. "How do I implement algorithm X in C?" is not a
question about a C implementation of an algorithm, it is a
request for source code. Newsgroups comp.programming and
comp.theory may be appropriate.

* Making C interoperate with other languages. C has no
facilities for such interoperation. These questions should
be directed to system- or compiler-specific newsgroups. C++
has features for interoperating with C, so consider
comp.lang.c++ for such questions.

* The C standard, as opposed to standard C. Questions about
the C standard are best asked in comp.std.c.

* C++. Please do not post or cross-post questions about C++
to comp.lang.c. Ask C++ questions in C++ newsgroups, such
as comp.lang.c++ or comp.lang.c++.moderated.

* Test posts. Please test in a newsgroup meant for testing,
such as alt.test.

news.groups.questions is a good place to ask about the appropriate
newsgroup for a given topic.

--
Go not to Usenet for counsel, for they will say both no and yes.
Jul 16 '06 #2
se******@yahoo.com writes:
I have two ethernet interfaces on my system, with IPs assigned to the
interfaces from different subnets (e.g. eth1 - 10.10.10.10 and eth2 -
20.20.20.20 ). I'm connecting these interfaces to a home gateway or
router. The 'eth1' interface connects to LAN interface of the router
with IP address 10.10.10.1 and the 'eth2' interface connects to WAN
interface of the router with IP address 20.20.20.1.
[...]
I'd appreciate if any one could help me with the solution to my above
problem, either with explanation or through sample code.
Standard C has no networking support. Try comp.unix.programmer or one
of the Linux groups.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 16 '06 #3
Sorry for posting to the wrong groups. And thanks for pointing me to
the right ones.

Thanks,
Seets.
Ben Pfaff wrote:
se******@yahoo.com writes:
Why does the socket connection bypass the router? Is there a way to
ensure that my socket connection goes through the router, instead of
creating a local connection?

Your question is outside the domain of comp.lang.c, which discusses
only the standard C programming language, including the standard C
library. This is a remarkably narrow topic compared to what many
people expect.

For your convenience, the list below contains topics that are not
on-topic for comp.lang.c, and suggests newsgroups for you to explore
if you have questions about these topics. Please do observe proper
netiquette before posting to any of these newsgroups. In particular,
you should read the group's charter and FAQ, if any (FAQs are
available from www.faqs.org and other sources). If those fail to
answer your question then you should browse through at least two weeks
of recent articles to make sure that your question has not already
been answered.

* OS-specific questions, such as how to clear the screen,
access the network, list the files in a directory, or read
"piped" output from a subprocess. These questions should be
directed to OS-specific newsgroups, such as
comp.os.ms-windows.programmer.misc, comp.unix.programmer, or
comp.os.linux.development.apps.

* Compiler-specific questions, such as installation issues,
locations of header files, configuring your C development
environment, or choosing or managing profiling tools,
debuggers, or code coverage tools. Ask about these in
compiler-specific newsgroups, such as gnu.gcc.help or
comp.os.ms-windows.programmer.misc. Questions about writing
compilers are appropriate in comp.compilers.

* Library-specific questions, such as how to use GLib, Kazlib,
libavl, libsndfile, GMP, GNU GSL, djbfft, CLAPACK, CBLAS,
libtomcrypt, etc. Ask about these in library-specific
newsgroups or mailing lists.

* Processor-specific questions, such as questions about
assembly and machine code. x86 questions are appropriate in
comp.lang.asm.x86, embedded system processor questions may
be appropriate in comp.arch.embedded.

* ABI-specific questions, such as how to interface assembly
code to C. These questions are both processor- and
OS-specific and should typically be asked in OS-specific
newsgroups.

* Algorithms, except questions about C implementations of
algorithms. "How do I implement algorithm X in C?" is not a
question about a C implementation of an algorithm, it is a
request for source code. Newsgroups comp.programming and
comp.theory may be appropriate.

* Making C interoperate with other languages. C has no
facilities for such interoperation. These questions should
be directed to system- or compiler-specific newsgroups. C++
has features for interoperating with C, so consider
comp.lang.c++ for such questions.

* The C standard, as opposed to standard C. Questions about
the C standard are best asked in comp.std.c.

* C++. Please do not post or cross-post questions about C++
to comp.lang.c. Ask C++ questions in C++ newsgroups, such
as comp.lang.c++ or comp.lang.c++.moderated.

* Test posts. Please test in a newsgroup meant for testing,
such as alt.test.

news.groups.questions is a good place to ask about the appropriate
newsgroup for a given topic.

--
Go not to Usenet for counsel, for they will say both no and yes.
Jul 17 '06 #4
se******@yahoo.com writes:
Sorry for posting to the wrong groups. And thanks for pointing me to
the right ones.
A couple of tips:

Please don't top-post. See <http://www.caliburn.nl/topposting.html>.

Quoting context is good, but quote only what's relevant to your
followup. A few lines of Ben Pfaff's post would have been sufficient
to make the context clear.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 17 '06 #5

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

Similar topics

4
by: Fuzzyman | last post by:
In a nutshell - the question I'm asking is, how do I make a socket conenction go via a proxy server ? All our internet traffic has to go through a proxy-server at location 'dav-serv:8080' and I...
6
by: Anders Both | last post by:
If you send data using TCP and Socket, can the client then be 100% sure that if it send´s data and no exception uccur, then the data will also arrived in a a correct way on the server. What if...
7
by: Adam Clauss | last post by:
I am trying to work-around a firewall which limits me to only being able to accept inbound connections on port 80. Unfortunately, I need to two different applications to be able to accept...
13
by: coloradowebdev | last post by:
i am working on basically a proxy server that handles requests via remoting from clients and executes transactions against a third-party server via TCP. the remoting site works like a champ. my...
5
by: Arno | last post by:
reposted with the right microsoft managed newsgroup ID: Sorry for the inconvinience Hi, I've written a class for client-socket connection, but I get a lot of times the error message "Unable...
5
by: darthghandi | last post by:
I've created a class to listen to all interfaces and do a BeginAccept(). Once it gets a connection, it passes the connected socket off and stores it in a List. Next, it continues to listen for...
3
by: xincmu | last post by:
I built a very basic server-client in C#. When my server disconnects from the client, the socket at the server is already disconnected, but the socket the client remains open. I used the sample...
11
by: weird0 | last post by:
I am a beginner to socket programming to in c#. I know the concepts as to how to program them. I get the above exception when i tried writing the code for the server side on the line...
9
by: cnixuser | last post by:
Hi, I was wondering if someone could give me some general pointers about creating client server applications that would be able to communicate with each other over not just the LAN which I am able...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.