473,795 Members | 3,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exception: A socket operation has encountered a dead network

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 tcpListener.Sta rt()
when i passed the localhost ip and port no. 4000:

Please help...

namespace Server
{
class Server
{
TcpListener tcpListener;
IPAddress ipAddress;
IPEndPoint remoteEP;

public Server(string ipaddress, int Port)
{
ipAddress = IPAddress.Parse (ipaddress);
tcpListener = new TcpListener(ipA ddress,Port);
remoteEP = new IPEndPoint(ipAd dress, Port);
}

public void Start()
{
try
{
tcpListener.Sta rt(); // line of exception
}
catch (Exception ex)
{
MessageBox.Show ("Problem:" + ex.Message);
}
}

public void Stop()
{
tcpListener.Sto p();
}

}

}

Jul 8 '07
11 4597

"Peter Duniho" <Np*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
On Thu, 12 Jul 2007 07:33:50 -0700, Michael D. Ober
<obermd.@.alum. mit.edu.nospamw rote:
>OP's code was setting up a listener socket. You need one of your local
IPs
(other than 127.0.0.1) for an external system to be able to connect to
it.
If you use 127.0.0.1 only applications on your local system can connect.

All true statements. So?

Have you never used your localhost address for testing purposes?
Yes I have.
>
It's not a good idea to specify _any_ specific IP address for a listening
socket anyway. But if one is going to do so, there's nothing
fundamentally wrong with using the localhost address versus some other
locally valid address.
If your network adapters, and thus, IP Addresses, are on different networks
and you want only traffic from one of the networks, you must specify the
address. On most systems, this isn't an issue, but it can be.

Mike.
Jul 12 '07 #11
On Thu, 12 Jul 2007 12:38:51 -0700, Michael D. Ober
<obermd.@.alum. mit.edu.nospamw rote:
If your network adapters, and thus, IP Addresses, are on different
networks
and you want only traffic from one of the networks, you must specify the
address. On most systems, this isn't an issue, but it can be.
Yup. There certainly are cases where binding to a specific IP address is
needed. I was speaking of the general case, and in any case none of that
suggests that the OP wasn't using the basic localhost address.
Jul 13 '07 #12

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

Similar topics

3
5135
by: David | last post by:
Hi, Ive been trying to work this out for the past 2 days now and im not getting anywhere fast. The problem i have is that i am using Asynchronous sockets to create a Socket Client library. When i try to connect to a server that doesnt exist it raises a "Connection forcibly rejected by the resmote host" SocketException.
4
3856
by: Frank Meng | last post by:
Hi. I am trying a csharp sample from http://www.codeproject.com/csharp/socketsincs.asp . (Sorry I didn't post all the source codes here, please get the codes from above link if you want to try). I had some troubles when I started 6 threads (each thread made a separate connection) and sent messages to same server simultaneously. Sometimes, not always, the socket looks like ok, but really it is dead. I don't why it happens.
4
2748
by: Qingdong Z. | last post by:
I have an asynchronous Server Socket to push data to client (Socket.BeginSend) when data is available, Meanwhile, the client socket use Synchronous Client Socket to receive the data. I have two questions on this 1. When client socket does not receive data as fast as server, does server socket queues all the data, or just waits? If it queues, this may kill server 2. I declare socket receive buffer big enough, when I call Socket.Receive...
1
1532
by: Simon M | last post by:
Hi, I'm not sure where to post this as it's about windows forms, web forms, socket communication and embedded objects. I am developing a smart client which is embedded in a webform. This client software communicates with a third party windows service over sockets. However I have a weird exception being raised in the AppDomain that I can't handle. When I finish the socket communication (all asyncronous) I popup a modal winform, which...
6
13022
by: Aero | last post by:
Hi, My window application written in C# is throwing following exception while connecting to one FTP location The type initializer for System.Net.Sockets.Socket threw an exception This exe is working fine on staging environment, (Window 2003) but after migrating to production environment (Windows 2000), throwing this exception at
6
27351
Frinavale
by: Frinavale | last post by:
Hi there, I'm not sure if anyone here can help me but I'm pretty desperate at this point. I've developed a web application that sends emails periodically. Everything works fine in the test environment (Visual Studio 2005's server emulator) but not when I publish it to the real IIS server. The IIS server is on the same machine that I am developing on. After reviewing the Windows Event log I discovered that our WinSock firewall is...
10
3590
by: John Nagle | last post by:
Here are three network-related exceptions. These were caught by "except" with no exception type, because none of the more specific exceptions matched. This is what a traceback produced: 1. File "D:\Python24\lib\socket.py", line 295, in read data = self._sock.recv(recv_size) timeout: timed out
2
18381
by: kodart | last post by:
Introduction Performance is the main concern to most server application developers. That’s why many of them anticipate using .NET platform to develop high performance server application regardless of the security features it provides. Microsoft Windows provides a high performance model that uses I/O completion port (IOCP) to process network events. IOCP provides best performance, but difficult to use due to lack of good code samples and...
2
4415
by: senglory | last post by:
My WCF: public interface IWorkbookService { DataTable GetDownpayments(KeyValuePair<int, string> sgm); } class WorkbookService : IWorkbookService
0
10214
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10001
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...
0
9042
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7540
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
6780
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();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
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
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.