Listen On a Certain Port  
Author Message
xlordt





PostPosted: Winsock Kernel (WSK), Listen On a Certain Port Top

I dont know if this is the right place for this.. but lets hope so... Im trying to create a simple... app that will listen on a certain port.. but for some reason It listen.. the program starts but.. then it ends... I also dont get any errors.. So Im a big lost here..

using System;
using System.Net;
using System.Net.Sockets;

class internetcheck
{
public static void Main( )
{
new startConnection();
}
}

class startConnection
{
public startConnection( )
{
Socket socket = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );

IPAddress ipaddr = IPAddress.Parse( "127.0.0.1" );
IPEndPoint endpoint = new IPEndPoint( ipaddr, 888 );

socket.Bind( endpoint );
socket.Listen(2);

//socket.Close();
}
}

Can anyone see, if they can spot something wrong here.



Windows Networking Development11  
 
 
xlordt





PostPosted: Winsock Kernel (WSK), Listen On a Certain Port Top

never mind.. I forgot to add socket.accept()


 
 
Brian Shafer





PostPosted: Winsock Kernel (WSK), Listen On a Certain Port Top

where does the socket.accpet() go
 
 
Mike Flasko





PostPosted: Winsock Kernel (WSK), Listen On a Certain Port Top

The accept goes after Socket.Listen. In the future please post all System.Net / .Net framework networking questions in the .Net Networking forum:

http://forums.microsoft.com/MSDN/ShowForum.aspx ForumID=40&SiteID=1