473,569 Members | 2,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# simple TCP Server/client problem

Hi, I have a simple TCP server client in .net and for some reason the
Accept() function in the Server part never gets called and never
returns a new socket. This thing has been driving me nuts for days,
here is the code please help if you can (the two machines that I am
trying to connect are on a LAN Ethernet):

Client()
{
Socket dcspTCPClient = null;

try
{
dcspTCPClient = new Socket
(AddressFamily. InterNetworkSoc ketType.Stream, ProtocolType.Tc p);

IPAddress remoteIPAddress =
(Dns.Resolve(st rHostName)).Add ressList[0];
IPEndPoint serverIPEndPoin t = new
IPEndPoint(remo teIPAddress,nSe rverPort);
EndPoint serverEndPoint = (EndPoint)serve rIPEndPoint;

dcspTCPClient.C onnect(serverEn dPoint);

}
catch (Exception error)
{
string strError = "TCPClient Error: "+error.ToStrin g();
}

}

private Socket m_tcpServer;

server()
{
try
{
IPEndPoint Ipep = new IPEndPoint(IPAd dress.Any, nPortListen);
m_tcpServer = new Socket(AddressF amily.InterNetw ork,
SocketType.Stre am, ProtocolType.Tc p);

m_tcpServer.Bin d(Ipep);
m_tcpServer.Lis ten(nClients);
}
while(true)
{
try
{
Socket sockAcceptClien t = m_tcpServer.Acc ept();

if(sockAcceptCl ient.Connected)
{
ThreadPool.Queu eUserWorkItem(n ew
WaitCallback(tc pMServerReceive Send), sockAcceptClien t);

}
}
catch(SocketExc eption se)
{
string strSocketExepti on = se.ToString();
}
}
}
catch (SocketExceptio n se)
{
string strSock = "createTCPServe rMultithread error:
"+se.ToString() ;
}
}

It looks like it is connecting fine but Accept never gets called on
the server side.
Nov 15 '05 #1
0 1355

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

Similar topics

1
9017
by: Johannes Eble | last post by:
Hello Python community, I am trying the echo-client and echo-server examples in Chapter 10, "Programming Python" by Mark Lutz. It is probably the most simple sockets sample: A socket server just echoing the socket clients' requests. The program works so far. I first start the server in one dos box, then the client in another dos box on...
3
2480
by: MBW | last post by:
The following code is for a simple server/client asplication that allows the user to toggle between serve and or client modes and send/recieve a message however i am getting an Attribute error on my entry widgets when I try and call get() to get the port and ip address from those fields, I'm sure it's something simple I haven't grasped... ...
2
8377
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the...
7
1492
by: Steven | last post by:
Hello, First, let me state that I am trying to learn asp.net, so I am a beginner. Now on to the issue. I have a webform with a single Textbox and a FileSystemWatcher monitoring a directory for OnCreate events. I am trying to change the text in response to an OnCreate event. I would like to change the Forecolor to red, from black. ...
18
3020
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How ??
0
2160
by: Harley | last post by:
Hello, I am just learning the tcp/ip functions etc under vb.net so please look over me if this is obviouse. I have been all over looking into any functions that I didn't totaly understand and can't see that I am doing anything wrong (i obviousely am though) everything "works", client connects to server and when anything is sent to the...
6
2267
by: Marc | last post by:
How could I directly trigger a very simple on localhost and a known port listening server from my internet browser client? Local host means the little server would be running on the client machine, where my browser resides. Browser would be IE, O.S. Windows 2000 or XP, and it's for an intranet application. The goal of the little server on the...
2
5174
by: Vitali Gontsharuk | last post by:
Hi! I have a problem programming a simple client-server game, which is called pingpong ;-) The final program will first be started as a server (nr. 2) and then as a client. The client then sends the message "Ping" to the server, which reads it and answers with a "Pong". The game is really simple and the coding should be also very simple!...
4
3926
by: shreedhan | last post by:
hi i am trying to write a simple client server chat program. the code of server program is: #define PORT 9999 int main() { struct sockaddr_in server_addr,client_addr;
10
2117
by: Phillip Taylor | last post by:
Hi guys, I'm looking to develop a simple web service in VB.NET but I'm having some trivial issues. In Visual Studio I create a web services project and change the asmx.vb file to this: Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.ComponentModel <System.Web.Services.WebService(Namespace:="http://...
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7917
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. ...
0
8118
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...
1
7665
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...
0
5217
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...
0
3651
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...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
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...

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.