Socket Help!!!
-
Hi I am trying to create a server that would accept and receive message from multiple client. But i am receiving SOCKET_ERROR while my server seems to accept the multiple connection. Could anyone correct my code. Here is the code I wrote.. CMysocket m_sListenSocket; <pre>void CLocalDlg::OnAccept(void) { CMysocket *pSocket = new CMysocket; if(m_sListenSocket.Accept(*pSocket)) MessageBox("Connection Accepted"); } For receiving: <pre>void CLocalDlg::OnReceive(void) { CMysocket *pSocket = new CMysocket; char *pBuff = new char[1024]; int stlen = 1025; int iRcvd; iRcvd = pSocket->Receive(pBuff, stlen); if(iRcvd ==SOCKET_ERROR) MessageBox("Received socket error"); else MessageBox("Message Received properly"); }
-
Hi I am trying to create a server that would accept and receive message from multiple client. But i am receiving SOCKET_ERROR while my server seems to accept the multiple connection. Could anyone correct my code. Here is the code I wrote.. CMysocket m_sListenSocket; <pre>void CLocalDlg::OnAccept(void) { CMysocket *pSocket = new CMysocket; if(m_sListenSocket.Accept(*pSocket)) MessageBox("Connection Accepted"); } For receiving: <pre>void CLocalDlg::OnReceive(void) { CMysocket *pSocket = new CMysocket; char *pBuff = new char[1024]; int stlen = 1025; int iRcvd; iRcvd = pSocket->Receive(pBuff, stlen); if(iRcvd ==SOCKET_ERROR) MessageBox("Received socket error"); else MessageBox("Message Received properly"); }
Did you preview your post? The <pre> tags are not working.
reddy07 wrote:
iRcvd = pSocket->Receive(pBuff, stlen);
What is
pSocket
connected to?"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Did you preview your post? The <pre> tags are not working.
reddy07 wrote:
iRcvd = pSocket->Receive(pBuff, stlen);
What is
pSocket
connected to?"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Hi I am trying to create a server that would accept and receive message from multiple client. But i am receiving SOCKET_ERROR while my server seems to accept the multiple connection. Could anyone correct my code. Here is the code I wrote.. CMysocket m_sListenSocket; <pre>void CLocalDlg::OnAccept(void) { CMysocket *pSocket = new CMysocket; if(m_sListenSocket.Accept(*pSocket)) MessageBox("Connection Accepted"); } For receiving: <pre>void CLocalDlg::OnReceive(void) { CMysocket *pSocket = new CMysocket; char *pBuff = new char[1024]; int stlen = 1025; int iRcvd; iRcvd = pSocket->Receive(pBuff, stlen); if(iRcvd ==SOCKET_ERROR) MessageBox("Received socket error"); else MessageBox("Message Received properly"); }
Alo, Pero perdon. Gracias. Adias Troy :laugh: ;P :rolleyes: :omg: