Click here to Skip to main content
15,902,275 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: International Software Pin
Olli23-Mar-03 19:46
Olli23-Mar-03 19:46 
GeneralRe: International Software Pin
John R. Shaw21-Mar-03 10:27
John R. Shaw21-Mar-03 10:27 
GeneralRe: International Software Pin
Olli23-Mar-03 19:48
Olli23-Mar-03 19:48 
Generala small problem with windows messages (SDK) Pin
r i s h a b h s20-Mar-03 19:54
r i s h a b h s20-Mar-03 19:54 
GeneralRe: a small problem with messages (SDK) Pin
Oliver Anhuth20-Mar-03 20:58
Oliver Anhuth20-Mar-03 20:58 
GeneralRe: a small problem with messages (SDK) Pin
r i s h a b h s20-Mar-03 22:05
r i s h a b h s20-Mar-03 22:05 
GeneralRe: a small problem with messages (SDK) Pin
Oliver Anhuth20-Mar-03 22:12
Oliver Anhuth20-Mar-03 22:12 
Generalsocket question (listen, accept) Pin
Daniel Strigl20-Mar-03 19:42
Daniel Strigl20-Mar-03 19:42 
I have a MFC (server) application that works with sockets.

It should do the following:

1. Waits for an incomming client connection request (only 1).
2. Accept that connection request.
3. Send something to the client.
4. Receive something from the client.
5. Close the accepted connection.
6. ... go to 1. (wait for incomming client connection request)

Only 1 client can send something to the server.

So, I tried to imeplement it like this:

WSAStartup(...);

server = socket(...);

bind(server, ...);

listen(server, ...);

client = accept(server, ...);

send(client, ...);

recv(client, ...);

closesocket(client);

...


So... my question!

This code runs in a own thread and should never ends (only when the user terminates the app).

After ther closesocket(client); when I want to re-listen to some incomming
connection request, have I to call only client = accept(server,...); or
listen(server,...); client = accept(server,...);?

What's the wright way:

WSAStartup(...);

server = socket(...);

bind(server, ...);

place <code>while (TRUE) {</code> here ???

listen(server, ...);

or place <code>while (TRUE) {</code> here ???

client = accept(server, ...);

send(client, ...);

recv(client, ...);

closesocket(client);

<code>} // while (TRUE) ...<code>


Daniel Wink | ;)
---------------------------
Never change a running system!
GeneralRe: socket question (listen, accept) Pin
Joaquín M López Muñoz20-Mar-03 20:00
Joaquín M López Muñoz20-Mar-03 20:00 
GeneralRe: socket question (listen, accept) Pin
Daniel Strigl20-Mar-03 20:10
Daniel Strigl20-Mar-03 20:10 
GeneralRe: socket question (listen, accept) Pin
Olli20-Mar-03 20:19
Olli20-Mar-03 20:19 
GeneralRe: socket question (listen, accept) Pin
Daniel Strigl20-Mar-03 21:08
Daniel Strigl20-Mar-03 21:08 
QuestionHow toget notification when any program or executable terminates Pin
Kumar Siddhartha20-Mar-03 18:51
Kumar Siddhartha20-Mar-03 18:51 
AnswerRe: How toget notification when any program or executable terminates Pin
Nish Nishant20-Mar-03 20:02
sitebuilderNish Nishant20-Mar-03 20:02 
GeneralRe: How toget notification when any program or executable terminates Pin
Anonymous20-Mar-03 20:56
Anonymous20-Mar-03 20:56 
GeneralEfficient string searching (advice required) Pin
paulhans20-Mar-03 18:21
paulhans20-Mar-03 18:21 
GeneralRe: Efficient string searching (advice required) Pin
Joaquín M López Muñoz20-Mar-03 20:08
Joaquín M López Muñoz20-Mar-03 20:08 
GeneralRe: Efficient string searching (advice required) Pin
Gunnar Bolle20-Mar-03 21:45
Gunnar Bolle20-Mar-03 21:45 
GeneralRe: Efficient string searching (advice required) Pin
Joaquín M López Muñoz20-Mar-03 21:54
Joaquín M López Muñoz20-Mar-03 21:54 
GeneralRe: Efficient string searching (advice required) Pin
Gunnar Bolle20-Mar-03 21:59
Gunnar Bolle20-Mar-03 21:59 
GeneralRe: Efficient string searching (advice required) Pin
jhwurmbach20-Mar-03 23:06
jhwurmbach20-Mar-03 23:06 
GeneralRe: Efficient string searching (advice required) Pin
John R. Shaw21-Mar-03 11:23
John R. Shaw21-Mar-03 11:23 
GeneralRe: Efficient string searching (advice required) Pin
John R. Shaw21-Mar-03 11:31
John R. Shaw21-Mar-03 11:31 
QuestionHow to Translae a Mapped Drive to a UNC Path Pin
Xilin20-Mar-03 17:20
Xilin20-Mar-03 17:20 
AnswerRe: How to Translae a Mapped Drive to a UNC Path Pin
saierdia20-Mar-03 18:28
saierdia20-Mar-03 18:28 

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.