Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hi i am new to c# and also sock

Status
Not open for further replies.

fuadhamidov

Programmer
Sep 22, 2003
98
TR
hi

i am new to c# and also socket programming. we have developed a small chat program. it connects to localhost. while we try to connect to remote machine with IP+port it doesn't connect.

our program listen from any defined port. and the other part begin to send message to given IP+port

...
//ipLocalEndPoint is IP+port; (127.0.0.1:3000)
//nSoc = 0;
SocClient[nSoc].AsyConnectTCIP(ipLocalEndPoint);
//it calls following method (AsyConnectTCIP)
...
//public Socket Soc;
public void AsyConnectTCIP(EndPoint remoteEP)
{
this.remoteEP =remoteEP;
AsyncCallback beginConnectCallback = new AsyncCallback(ConnectCallBack);
Soc.BeginConnect(remoteEP,beginConnectCallback,Soc);
//it doesn't connect to remote IP+port and goes following mehtod (OnCloseRemote)
}


...
public event CloseDelegate OnConnectClose;
...
// not important. it prints error message
private void OnCloseRemote(object sender, SockEventArgs e)
{
label1.Text = "Remote Close";
nClose +=1;
//txtClose.Text = nClose.ToString();
foreach (ListViewItem aa in listView1.Items)
{
if (aa.Text == e.SocketRef.ToString())
{
listView1.Items.Remove(aa);
break;
}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top