Click here to Skip to main content
15,914,163 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionChoosing of STL container Pin
hrishiS15-Dec-09 23:35
hrishiS15-Dec-09 23:35 
AnswerRe: Choosing of STL container Pin
Adam Roderick J16-Dec-09 0:05
Adam Roderick J16-Dec-09 0:05 
GeneralRe: Choosing of STL container Pin
hrishiS16-Dec-09 0:52
hrishiS16-Dec-09 0:52 
AnswerRe: Choosing of STL container Pin
Jonathan Davies16-Dec-09 0:06
Jonathan Davies16-Dec-09 0:06 
GeneralRe: Choosing of STL container Pin
hrishiS16-Dec-09 0:52
hrishiS16-Dec-09 0:52 
AnswerRe: Choosing of STL container Pin
CPallini16-Dec-09 0:08
mveCPallini16-Dec-09 0:08 
AnswerRe: Choosing of STL container Pin
KingsGambit16-Dec-09 1:00
KingsGambit16-Dec-09 1:00 
QuestionThreads and Sockets Pin
giancoitaly15-Dec-09 21:56
giancoitaly15-Dec-09 21:56 
Hi all,
I have a problem with sockets inside a thread: it seems the socket object is not working inside the thread.

I'm using a Socket library found on the net and the "socket.h" library from windows.

This code works:
<br />
SocketClient s(ServerAdress, ServerPort);<br />
s.SendLine("aaa");<br />
while (1) <br />
{<br />
  string l = s.ReceiveLine();<br />
  if (l.empty()) break;<br />
  cout << l;<br />
   cout.flush();<br />
}<br />


Now I'm trying to do the same thing in a thread... I have a function:
<br />
void Answer(void* param) <br />
{  <br />
  SocketClient* ps = (SocketClient*)param;<br />
  ps->SendLine("GET / HTTP/1.0");<br />
  ps->SendLine("Host: www.google.com");<br />
  ps->SendLine("");<br />
<br />
  while (1) <br />
  {<br />
    string l = ps->ReceiveLine();<br />
    if (l.empty()) break;<br />
    cout << l;<br />
    cout.flush();<br />
  }<br />
  delete ps;<br />
} <br />


And I call it in this way:
<br />
_beginthread(Answer, 0, &s);<br />


All is compiling fine, but then the Socket inside the thread seems to be useless, it doesn't do nothing.

Can anyone explain me how to pass object between threads?

Is there a possibility to pass them without pointers?

I'm quite new in C++ and I found nothing on the net so far.

Thanks!
gianca
AnswerRe: Threads and Sockets [modified] Pin
Adam Roderick J15-Dec-09 23:31
Adam Roderick J15-Dec-09 23:31 
QuestionIs it possible to change the dll versions Pin
pandit8415-Dec-09 21:30
pandit8415-Dec-09 21:30 
AnswerRe: Is it possible to change the dll versions Pin
KingsGambit15-Dec-09 21:56
KingsGambit15-Dec-09 21:56 
GeneralRe: Is it possible to change the dll versions Pin
pandit8415-Dec-09 22:14
pandit8415-Dec-09 22:14 
QuestionHow to implement edit box and spin control Pin
deadlyabbas15-Dec-09 19:46
deadlyabbas15-Dec-09 19:46 
AnswerRe: How to implement edit box and spin control Pin
Adam Roderick J15-Dec-09 19:56
Adam Roderick J15-Dec-09 19:56 
GeneralRe: How to implement edit box and spin control Pin
deadlyabbas15-Dec-09 20:29
deadlyabbas15-Dec-09 20:29 
GeneralRe: How to implement edit box and spin control Pin
Adam Roderick J16-Dec-09 0:01
Adam Roderick J16-Dec-09 0:01 
GeneralRe: How to implement edit box and spin control Pin
deadlyabbas16-Dec-09 0:04
deadlyabbas16-Dec-09 0:04 
GeneralRe: How to implement edit box and spin control Pin
Adam Roderick J16-Dec-09 0:10
Adam Roderick J16-Dec-09 0:10 
AnswerRe: How to implement edit box and spin control Pin
KingsGambit15-Dec-09 21:06
KingsGambit15-Dec-09 21:06 
GeneralRe: How to implement edit box and spin control Pin
deadlyabbas15-Dec-09 23:23
deadlyabbas15-Dec-09 23:23 
GeneralRe: How to implement edit box and spin control Pin
KingsGambit15-Dec-09 23:29
KingsGambit15-Dec-09 23:29 
GeneralRe: How to implement edit box and spin control Pin
deadlyabbas15-Dec-09 23:37
deadlyabbas15-Dec-09 23:37 
GeneralRe: How to implement edit box and spin control Pin
deadlyabbas16-Dec-09 0:01
deadlyabbas16-Dec-09 0:01 
GeneralRe: How to implement edit box and spin control Pin
KingsGambit16-Dec-09 0:40
KingsGambit16-Dec-09 0:40 
QuestionHow to use WIN32_FIND_DATA to find whole disk drive ? Pin
wangningyu15-Dec-09 14:04
wangningyu15-Dec-09 14:04 

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.