Sometimes when I use Loopback as the COmputer name is goes frozen. Im using the same application to connect and host, (loaded twice obviously). It seems to work fine without error most the time but I cant seem to send and recieve. I dont even know if I am connecting to the application. Can anyone see any obvious mistakes here? These are all functions, each one for a diffrent button in the simplest of message sending applications.

mBox And Sbox are Message Box (Output) and Send Box (Message to be sent, A CSTRING type in the MFC Library).

HELLLLLLLLPPPPPPPPPP ! :-)

void CSock2Dlg::Onclient()
{
m_socket.Create() ;
m_socket.Connect("loopback",4000) ;
}

void CSock2Dlg::Onexit()
{
OnOK();
}

void CSock2Dlg::Onserver()
{
m_socket.Create(4000) ;
m_socket.Listen() ;



}

void CSock2Dlg::Onaccept()
{
m_socket.Accept(m_socket2) ;

}

void CSock2Dlg::Onsend()
{
CString strMyMessage;
strMyMessage = m_sbox ;
int iLen;
iLen = strMyMessage.GetLength();
m_socket.Send(LPCTSTR(strMyMessage), iLen);
}

void CSock2Dlg::Onrecieve()
{
char *pBuf = new char[1025];
int iBufSize = 1024;
int iRcvd;
CString strRecvd;
iRcvd = m_socket.Receive(pBuf, iBufSize);
if (iRcvd == SOCKET_ERROR)
{
// Do some error handling here
}
else
{
pBuf[iRcvd] = NULL;
strRecvd = pBuf;
// Continue processing the message
}

m_mbox = strRecvd ;
UpdateData(FALSE) ;

}