i cant receive pocket
-
Tuesday, March 27, 2012 6:03 AM
hi guys
i want write a software to manage internet bind width in our office . for test this i write to part software(server and client working by tcp on port 80).
when i sent message from client to server it work but when i sent massage to ip out of my network server didnt receive.
i set client gateway to server ip.
server side code :
int servPort = 80;
Socket server = null;
try
{
// Create a socket to accept client connections
server = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);server.Bind(new IPEndPoint(IPAddress.Any, servPort));
server.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, true);
server.Listen(BACKLOG);
}
catch (SocketException se)
{
Console.WriteLine(se.ErrorCode + ": " + se.Message);
Environment.Exit(se.ErrorCode);
}Console.WriteLine("Server in Running ...");
byte[] rcvBuffer = new byte[BUFSIZE]; // Receive buffer
int bytesRcvd; // Received byte countfor (; ; )
{ // Run forever, accepting and servicing connectionsSocket client = null;
Console.WriteLine("Ready ... ");
try
{
client = server.Accept(); // Get client connectionConsole.Write("Handling client at " + client.RemoteEndPoint + " - ");
// Receive until client closes connection, indicated by 0 return value
int totalBytesEchoed = 0;
while ((bytesRcvd = client.Receive(rcvBuffer, 0, rcvBuffer.Length,
SocketFlags.None)) > 0)
{
client.Send(rcvBuffer, 0, bytesRcvd, SocketFlags.None);
totalBytesEchoed += bytesRcvd;
}
Console.WriteLine("echoed {0} bytes.", totalBytesEchoed);//client.Close(); // Close the socket. We are done with this client!
}
catch (Exception e)
{
Console.WriteLine(e.Message);
//client.Close();
}- Moved by Michael_HawkerMicrosoft Employee Tuesday, March 27, 2012 2:48 PM more appropriate forum (From:Network Monitor)
All Replies
-
Wednesday, March 28, 2012 3:30 AMTo diagnose this, can you run a "netstat -nab" while trying to connect local and see if the addresses being used matches (e.g.: IPv4 or IPv6 address?)

