Forum Discussion

reshma_bh's avatar
reshma_bh
New Contributor
11 years ago

Error: Only one usage of each socket address (protocol/network address/port) is normally permitted



Hi



I am trying to conenct to the server through TCp/Ip protocolu using VB script:

Sample code ref: http://support.smartbear.com/viewarticle/9004/ 



Can anyone help me in understanding the below error msg:

System.Net.Sockets.SocketException (0x80004005): Only one usage of each socket address (protocol/network address/port) is normally permitted.



Thanks,

Reshma
  • Hi Reshma,

     


    I think that the reason of the error is because socket was not closed.

     

    If your test failed and terminated before the socket was closed, you must either reopen test project or restart TestComplete (don't remember exactly, check what will work for you).

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Reshma,


     


    As far as I understand, you've posted the ready example here.


    Were you able to resolve the error? Please share with us what was the reason for it.


     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Reshma,

     


    I think that the reason of the error is because socket was not closed.

     

    If your test failed and terminated before the socket was closed, you must either reopen test project or restart TestComplete (don't remember exactly, check what will work for you).

  • reshma_bh's avatar
    reshma_bh
    New Contributor
    Alex



    What you siad might be true, Testcomplete got struck while executing the script and crashed. May be the socket didn't get closed. Tried either ways but not able to fix the issue.



    Any othe ralternatives 



  • Hello Dears

    I have a problem that i cant solve it

    i want to write a program that  pass data(message) from one ip to another.

    you can see my code  below and the error is:

    Only one usage of each socket address (protocol/network address/port) is normally permitted


    TcpListener listerner = new TcpListener(44444);



    TcpClient client;



    String message="";



    Object tts;



    Socket m_clientSocket;





    protected void Page_Load(object sender, EventArgs e)



    {



    if (Page.IsPostBack == false)



    {



    listerner.Start();



    Timer1.Enabled = true;



    TextBox4.Enabled = false;



    }



    }



    protected void Button1_Click(object sender, EventArgs e)



    {



    try



    {



    if (TextBox1.Text == "" | TextBox2.Text == "" | TextBox3.Text == "")



    {



    Label1.Text = "Sorry Uncomplete data";



    }



    else



    {



    client = new TcpClient(TextBox2.Text, 44444);



    StreamWriter writer = new StreamWriter(client.GetStream());



    writer.Write(TextBox1.Text + " says:" + TextBox3.Text);



    writer.Flush();



    TextBox3.Text = "";



    }



    }



    catch (Exception ex)



    {



    listerner.Stop();



    }



    }



    protected void Timer1_Tick(object sender, EventArgs e)



    {



    try



    {



    if (listerner.Pending())



    {



    message = "";



    client = listerner.AcceptTcpClient();



    StreamReader reader = new StreamReader(client.GetStream());



    while (reader.Peek() > -1)



    {



    message = message + Convert.ToChar(reader.Read()).ToString();



    }



    this.Focus();



    TextBox4.Text = (TextBox4.Text + message + "\n");



    SpVoice s = new SpVoice();



    s.Speak(message);



    }



    }



    catch



    {



    listerner.Stop();



     



    }



    }