Click here to Skip to main content
15,887,892 members
Home / Discussions / C#
   

C#

 
GeneralRe: Trouble binding with TCP to same local endpoint Pin
Richard MacCutchan1-Feb-15 6:05
mveRichard MacCutchan1-Feb-15 6:05 
NewsRe: Trouble binding with TCP to same local endpoint Pin
Mc_Topaz1-Feb-15 6:39
Mc_Topaz1-Feb-15 6:39 
AnswerRe: Trouble binding with TCP to same local endpoint Pin
Pete O'Hanlon2-Feb-15 6:31
mvePete O'Hanlon2-Feb-15 6:31 
GeneralRe: Trouble binding with TCP to same local endpoint Pin
Mc_Topaz2-Feb-15 19:57
Mc_Topaz2-Feb-15 19:57 
GeneralRe: Trouble binding with TCP to same local endpoint Pin
Pete O'Hanlon2-Feb-15 23:18
mvePete O'Hanlon2-Feb-15 23:18 
GeneralRe: Trouble binding with TCP to same local endpoint Pin
Mc_Topaz2-Feb-15 23:43
Mc_Topaz2-Feb-15 23:43 
AnswerRe: Trouble binding with TCP to same local endpoint Pin
DelphiCoder5-Feb-15 20:12
DelphiCoder5-Feb-15 20:12 
GeneralRe: Trouble binding with TCP to same local endpoint Pin
Mc_Topaz8-Feb-15 8:00
Mc_Topaz8-Feb-15 8:00 
Thanks for the suggestions but it failed as well Frown | :(

With netstat -b I still see that 172.168.0.10:20001 172.168.0.18:10002 is still in TIME_WAIT state after I called the Shutdown() method for the TCP-client.

I used this code to test:
C#
static void Test(IPEndPoint local, IPEndPoint remote, byte[] request)
{
    byte[] response = new byte[0];

    using (TcpClient tcp = new TcpClient())
    {
        try
        {
            tcp.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
            tcp.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, 0);
            tcp.LingerState = new LingerOption(false, 0);

            tcp.Client.Bind(local);
            tcp.Connect(remote);

            using (NetworkStream stream = tcp.GetStream())
            {
                try
                {
                    stream.Write(request, 0, request.Length);

                    Thread.Sleep(500);

                    response = new byte[tcp.Available];
                    stream.Read(response, 0, response.Length);
                }
                catch (SocketException soe)
                {
                    Console.WriteLine(soe.ErrorCode);
                    Console.WriteLine(soe.SocketErrorCode);
                    Console.WriteLine(soe.Message);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
        catch (SocketException soe)
        {
            Console.WriteLine(soe.ErrorCode);
            Console.WriteLine(soe.SocketErrorCode);
            Console.WriteLine(soe.Message);
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
        finally
        {
            if (tcp.Connected)
            {
                tcp.Client.Shutdown(SocketShutdown.Both);
            }
        }
    }

    Console.WriteLine("Received: {0} byte(s)", response.Length);
}




Any further suggestions?

/Steffe
GeneralRe: Trouble binding with TCP to same local endpoint Pin
DelphiCoder11-Feb-15 5:22
DelphiCoder11-Feb-15 5:22 
QuestionConversion of Text Box Hindi Value to Unicode to store in database in hindi Pin
Member 1080107431-Jan-15 21:04
Member 1080107431-Jan-15 21:04 
AnswerRe: Conversion of Text Box Hindi Value to Unicode to store in database in hindi Pin
Afzaal Ahmad Zeeshan31-Jan-15 21:44
professionalAfzaal Ahmad Zeeshan31-Jan-15 21:44 
Questiondatatable method to return no value Pin
User 1138061131-Jan-15 8:06
User 1138061131-Jan-15 8:06 
GeneralRe: datatable method to return no value Pin
PIEBALDconsult31-Jan-15 8:41
mvePIEBALDconsult31-Jan-15 8:41 
GeneralRe: datatable method to return no value Pin
User 1138061131-Jan-15 8:52
User 1138061131-Jan-15 8:52 
AnswerRe: datatable method to return no value Pin
Mycroft Holmes31-Jan-15 21:03
professionalMycroft Holmes31-Jan-15 21:03 
AnswerRe: datatable method to return no value Pin
F-ES Sitecore2-Feb-15 6:31
professionalF-ES Sitecore2-Feb-15 6:31 
QuestionC# SendKeys + - ~ signs? Pin
Linus Agren31-Jan-15 7:38
Linus Agren31-Jan-15 7:38 
AnswerRe: C# SendKeys + - ~ signs? Pin
LLLLGGGG31-Jan-15 12:37
LLLLGGGG31-Jan-15 12:37 
GeneralRe: C# SendKeys + - ~ signs? Pin
Linus Agren1-Feb-15 5:59
Linus Agren1-Feb-15 5:59 
GeneralRe: C# SendKeys + - ~ signs? Pin
LLLLGGGG1-Feb-15 6:49
LLLLGGGG1-Feb-15 6:49 
QuestionC# Pin
Member 1116162531-Jan-15 4:23
Member 1116162531-Jan-15 4:23 
AnswerRe: C# Pin
LLLLGGGG31-Jan-15 4:32
LLLLGGGG31-Jan-15 4:32 
GeneralRe: C# Pin
OriginalGriff31-Jan-15 4:48
mveOriginalGriff31-Jan-15 4:48 
GeneralRe: C# Pin
LLLLGGGG31-Jan-15 5:11
LLLLGGGG31-Jan-15 5:11 
AnswerRe: C# Pin
OriginalGriff31-Jan-15 4:47
mveOriginalGriff31-Jan-15 4:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.