473,803 Members | 2,913 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't reach my machine using TCPClient

I've got a little rudimentary client-server app. One runs a server
listening to 'any' ip on a given port and the client attempts to
connect to the external ip of my app. I am on a LAN behind a router
and, undoubtedly, a firewall.

If I make the IP I am trying to connect to 127.0.0.1 everything works
fine but as long as I am using the external IP I can't get through and
I get an exception which states that the host is actively refusing the
connection.

Is this because I am behind a router? More importantly, if this is the
case how do applications manage to get around this. For example, if I
install some new random application, it seems to have no problem
connecting to a peer-to-peer server on some random port. But my app...
gets refused.

What am I missing?

Thanks!
Aug 26 '08 #1
2 2580

"9to5" <da**********@g mail.comwrote in message
news:d2******** *************** ***********@v39 g2000pro.google groups.com...
>
What am I missing?

http://www.homenethelp.com/web/expla...arding-dmz.asp

If you have a personal firewall running on the computer, you would need to
set a FW rule there too, to open the required port.

Keep the machine out of the DMZ

Aug 26 '08 #2
On Mon, 25 Aug 2008 20:54:36 -0700, 9to5 <da**********@g mail.comwrote:
I've got a little rudimentary client-server app. One runs a server
listening to 'any' ip on a given port and the client attempts to
connect to the external ip of my app. I am on a LAN behind a router
and, undoubtedly, a firewall.

If I make the IP I am trying to connect to 127.0.0.1 everything works
fine but as long as I am using the external IP I can't get through and
I get an exception which states that the host is actively refusing the
connection.

Is this because I am behind a router? More importantly, if this is the
case how do applications manage to get around this. For example, if I
install some new random application, it seems to have no problem
connecting to a peer-to-peer server on some random port. But my app...
gets refused.

What am I missing?
Well, first, it's important to distinguish between what your application
is doing and what "some new random application" might be doing. In
particular, NAT routers are not always explicitly firewalls, but even when
they aren't they exhibit some firewall-like behaviors. But these
behaviors are usually disabled when a client of the NAT router _initiates_
communication outbound.

So, if this "new random application" is on your LAN but connecting to an
IP address outside the LAN, the NAT router is handling that automatically,
acting as a proxy between the client on your LAN and the outside address.
When traffic comes back inbound, it's actually addressed to the NAT
router, but the NAT router knows which client it's proxying on that
address and forwards it on automatically.

You can configure this forwarding ("port forwarding") explicitly. In
practically all cases, the NAT router will let you do this manually. For
most modern NAT routers (anything built within the last 5 years, and
including some built even earlier) they will support "Universal Plug and
Play" which is a protocol that allows clients to discover and configure
the NAT router automatically. But you would have to write your
application to support that.

There are also techniques involving "tunneling" . UDP port tunneling is
particularly reliable, in spite of there being no official specification
to ensure that all NAT routers handle it, and there are techniques that
work (less often) for TCP. But it does depend on still having a known
intermediary server accessible to both clients trying to reach each other,
so if you're just trying to loop back through your Internet IP address,
that probably wouldn't be applicable.

Pete
Aug 26 '08 #3

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

Similar topics

2
2088
by: Jim W | last post by:
This is a cross-post from the .NET group since it looks like it may not be ..NET. New information since the original post is that is the wireless network is enabled and connected the socket connect time is 4x longer! Disable wireless and it is back down to just very slow. Any ideas are appreciated. -----
1
2015
by: Johann Blake | last post by:
Hi, I have come across a rather bizarre problem using the TcpClient to retrieve a web page. I use the TcpClient in conjunction with a StreamWriter to write a HTTP request to the web site. The web server returns either a 301, 302 or 404 code indicating that the page could not be found or has been redirected. If I issue the same URL using Internet Explorer (IE), it does retrieve the page. I then used a HTTP sniffer program to see what...
6
28466
by: MajorTom | last post by:
Hello, I getting this error An established connection was aborted by the software in your host machine here: TcpClient smtpSocket = new TcpClient(_serverSmtp, _portSmtp) port = 25 (smtp server) and my smtp server is working fine from the outlook program
8
1986
by: William Meitzen | last post by:
Does someone know how I can get two projects to share a common class? Something like this: solution WholeShmeer project1 code1 CommonClass project2 code2 CommonClass
0
1299
by: den 2005 | last post by:
Hi everybody, I am still learning how sockets, TcpClient and TcpListener work, in order that both sides to send and receive data, both sides must have a socket or TcpListener and a TcpListener right? Is there a possible way to say just have a client side TcpClient application to send a message to remote server like sending a text file? Do TcpClient requires a Internet connection to connect say to remote server? So, to connect to a VPN...
5
2184
by: TulasiKumar | last post by:
Hi all, I am new in Netwrok porgraming in cSharp.how can i detect Tcp/Ip packet in c#.Net.Any body knows please tell me, what are the interfaces or classes are supported regrading on TCP/IP packets.Please tell me any website refrences or any Source code examples.This is very urgent requirement. Thanks in advance, Regards, Tulasi Kumar.
7
5607
by: Lee | last post by:
Hey all, I'm using the following code to send stuff accross the network, appologies for it being in full, but I've really no idea exactly where this error is occuring. =======network code============ using System; using System.Net; using System.Net.Sockets; using System.Threading;
3
8207
by: RFD | last post by:
I've been slaving at this problem for over a week, and would appreciate some help from you kind folks. Basic Problem: I have made a server program and a client program. When I try to use the client to connect to 127.0.0.1 or my LAN IP, the program connects and transfers information successfully. However, when I get somebody else to host the server, or when I try to connect to a server on my own machine using my WAN IP, I currently get a...
0
1370
by: sternr | last post by:
Hey, I'm using a TcpClient to create HTTP requests to my web-server (I know of HttpWebRequest, it is mandatory for me to use TcpClient.). Here's my code: TcpClient tcp = new TcpClient(SERVER_IP, SERVER_PORT); tcp.NoDelay = true; string data = "GET http://" + SERVER_IP + SERVER_PORT + "/getData?id=1
0
9566
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10555
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10300
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7607
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2974
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.