Click here to Skip to main content
15,913,090 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralImages in CListCtrl report columns Pin
IGx895-Sep-02 15:50
IGx895-Sep-02 15:50 
QuestionHow can I know which computer access the file of my computer? Pin
Member 18556085-Sep-02 13:49
Member 18556085-Sep-02 13:49 
GeneralSending mail ... Pin
Hadi Rezaee5-Sep-02 12:57
Hadi Rezaee5-Sep-02 12:57 
GeneralRe: Sending mail ... Pin
Chris Losinger5-Sep-02 13:14
professionalChris Losinger5-Sep-02 13:14 
GeneralRe: Sending mail ... Pin
Hadi Rezaee5-Sep-02 13:26
Hadi Rezaee5-Sep-02 13:26 
GeneralRe: Sending mail ... Pin
Hadi Rezaee6-Sep-02 8:33
Hadi Rezaee6-Sep-02 8:33 
GeneralRe: Sending mail ... Pin
Chris Losinger6-Sep-02 11:20
professionalChris Losinger6-Sep-02 11:20 
GeneralCSocket new-b question Pin
Anonymous5-Sep-02 12:36
Anonymous5-Sep-02 12:36 
Hello,
I am trying to make a simple CSocket server that will accept multiple connections on the same port.. Here is what I have done.

On my Accept Connections function I do the following:
CMySocket* pSocket = new CMySocket();
	
pSocket->SetParent(this);

if (m_sListen.Accept(*pSocket))
{
	m_connectionList.AddTail(pSocket);		
}
else
	delete pSocket;

This seems to work.. I can see the m_connectionList grow with each connect..
m_connectionList is a CPtrList.

If only one client connects and sends data, Everything is fine.. Its when Multiple clients connect and I receive data from a client it seems to lock up the server until all the clients disconnect.

I know I am doing this receive function wrong.. How do i figure out what Socket is sending the information so I can receive it???

Here is my receive function

char *pBuf = new char[1025];
CString strRecvd;
int iRcvd;
int iConnections = m_connectionList.GetCount();

POSITION pos = m_connectionList.GetHeadPosition();

while(iConnections > 0)
{
	CMySocket* pSocket = (CMySocket*)m_connectionList.GetNext(pos);
		
	iRcvd = pSocket->Receive(pBuf,1024);
		

	// Did we a error, if not then proceed
	if (iRcvd == SOCKET_ERROR)
	{
		delete[] pBuf;
		AfxMessageBox("Socket error");
	}
	else
	{
        ......
        } 
         iConnections--;
}

I think the problem is in how I am storing the pointers to the Sockets.. but then again, I am new to this so I would be surprised if I am going about this the wrong way..

Any Ideas??
GeneralRe: CSocket new-b question Pin
jparsons5-Sep-02 12:38
jparsons5-Sep-02 12:38 
GeneralRe: CSocket new-b question Pin
anju5-Sep-02 18:45
anju5-Sep-02 18:45 
GeneralRegister DLL in App Pin
Anonymous5-Sep-02 12:05
Anonymous5-Sep-02 12:05 
GeneralRe: Register DLL in App Pin
Joaquín M López Muñoz5-Sep-02 12:20
Joaquín M López Muñoz5-Sep-02 12:20 
GeneralRe: Register DLL in App Pin
Anonymous5-Sep-02 12:29
Anonymous5-Sep-02 12:29 
GeneralRe: Register DLL in App Pin
Joaquín M López Muñoz5-Sep-02 12:41
Joaquín M López Muñoz5-Sep-02 12:41 
GeneralRe: Register DLL in App Pin
Anonymous5-Sep-02 13:24
Anonymous5-Sep-02 13:24 
GeneralCreating Custom Control Pin
MightyThor5-Sep-02 11:15
MightyThor5-Sep-02 11:15 
GeneralRe: Creating Custom Control Pin
Roger Allen6-Sep-02 2:06
Roger Allen6-Sep-02 2:06 
GeneralRe: Creating Custom Control Pin
MightyThor7-Sep-02 9:14
MightyThor7-Sep-02 9:14 
GeneralCTree, change selection on right click Pin
brianwelsch5-Sep-02 11:02
brianwelsch5-Sep-02 11:02 
GeneralRe: CTree, change selection on right click Pin
Tomasz Sowinski5-Sep-02 11:13
Tomasz Sowinski5-Sep-02 11:13 
GeneralRe: CTree, change selection on right click Pin
brianwelsch5-Sep-02 16:04
brianwelsch5-Sep-02 16:04 
GeneralVisual C++ book Pin
marekm5-Sep-02 10:45
marekm5-Sep-02 10:45 
GeneralRe: Visual C++ book Pin
brianwelsch5-Sep-02 10:53
brianwelsch5-Sep-02 10:53 
GeneralRe: Visual C++ book Pin
adamUK5-Sep-02 12:31
adamUK5-Sep-02 12:31 
GeneralRe: Visual C++ book Pin
valikac5-Sep-02 15:32
valikac5-Sep-02 15:32 

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.