Click here to Skip to main content
15,924,507 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionXML DOMDocument COM and windows service Pin
S-Andy4-Jul-06 2:17
S-Andy4-Jul-06 2:17 
QuestionFind focused control in CDialog? Pin
george ivanov4-Jul-06 2:13
george ivanov4-Jul-06 2:13 
AnswerRe: Find focused control in CDialog? Pin
Hamid_RT4-Jul-06 2:23
Hamid_RT4-Jul-06 2:23 
AnswerRe: Find focused control in CDialog? Pin
Sarath C4-Jul-06 2:23
Sarath C4-Jul-06 2:23 
QuestionRejecting connection from client Pin
Sarath C4-Jul-06 1:44
Sarath C4-Jul-06 1:44 
AnswerRe: Rejecting connection from client Pin
Matt Godbolt4-Jul-06 3:22
Matt Godbolt4-Jul-06 3:22 
GeneralRe: Rejecting connection from client Pin
Sarath C4-Jul-06 3:39
Sarath C4-Jul-06 3:39 
GeneralRe: Rejecting connection from client Pin
Matt Godbolt4-Jul-06 4:45
Matt Godbolt4-Jul-06 4:45 
In that instance then, once you've accept()ed the first connection, you can close the socket you created to listen on. Any further connection attempts will be rejected with 'connection refused'. Something like:

// Create a listening socket.
SOCKET listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
// Bind to local address (NB the localAddress is not initialised here; it's of type struct sockaddr*)
bind(listenSocket, localAddress);

// Start listening on this socket.  NB Passing a backlog of 1 here doesn't limit the number of connections to one.
listen(listenSocket, 1);

// Accept a connection
sockaddr_in connectingAddress;
int connectingAddressSize = sizeof(connectingAddress);
SOCKET incomingConnection = accept(listenSocket, &connectingAddress, &connectingAddressSize);

// We now have a socket 'incomingConnection' which we can read and write to to talk to the incoming connection.
// It's now safe to close the listening socket - effectively closing the port to any further connections.
closesocket(listenSocket);

// ...read and write to incomingConnection...

closesocket(incomingConnection);


NB this code is totally off the top of my head, so apologies if there's any compile issues, hopefully you get the idea!

Matt Godbolt
Engineer, ProFactor Software
StyleManager project
GeneralRe: Rejecting connection from client Pin
Sarath C4-Jul-06 5:35
Sarath C4-Jul-06 5:35 
Questionadd/cancel connection problem Pin
vivek bakshi4-Jul-06 1:41
vivek bakshi4-Jul-06 1:41 
QuestionHow to read and strore a .gif file in binary mode in vc++ [modified] Pin
Vinod Sankaranarayanan4-Jul-06 1:30
Vinod Sankaranarayanan4-Jul-06 1:30 
AnswerRe: How to read and strore a .gif file in binary mode in vc++ Pin
Sarath C4-Jul-06 1:42
Sarath C4-Jul-06 1:42 
AnswerRe: How to read and strore a .gif file in binary mode in vc++ Pin
_AnsHUMAN_ 4-Jul-06 1:44
_AnsHUMAN_ 4-Jul-06 1:44 
QuestionCreate bitmap Pin
Sarath C4-Jul-06 0:17
Sarath C4-Jul-06 0:17 
AnswerRe: Create bitmap Pin
Justin Tay4-Jul-06 0:39
Justin Tay4-Jul-06 0:39 
QuestionReplacing Windows' copy manager (?) Pin
smithjunior3-Jul-06 23:59
smithjunior3-Jul-06 23:59 
QuestionResize SpliterWnd on CFrameWnd Pin
huynhnb3-Jul-06 23:50
huynhnb3-Jul-06 23:50 
QuestionCommunication from Dialog to CFormView Pin
Uday Janaswamy3-Jul-06 23:36
Uday Janaswamy3-Jul-06 23:36 
AnswerRe: Communication from Dialog to CFormView Pin
Weiye Chen3-Jul-06 23:39
Weiye Chen3-Jul-06 23:39 
GeneralRe: Communication from Dialog to CFormView Pin
Uday Janaswamy4-Jul-06 3:17
Uday Janaswamy4-Jul-06 3:17 
AnswerRe: Communication from Dialog to CFormView Pin
huynhnb3-Jul-06 23:55
huynhnb3-Jul-06 23:55 
GeneralRe: Communication from Dialog to CFormView [modified] Pin
Uday Janaswamy4-Jul-06 3:07
Uday Janaswamy4-Jul-06 3:07 
GeneralRe: Communication from Dialog to CFormView Pin
huynhnb4-Jul-06 16:32
huynhnb4-Jul-06 16:32 
GeneralRe: Communication from Dialog to CFormView Pin
Uday Janaswamy4-Jul-06 18:36
Uday Janaswamy4-Jul-06 18:36 
GeneralRe: Communication from Dialog to CFormView Pin
Uday Janaswamy5-Jul-06 18:26
Uday Janaswamy5-Jul-06 18:26 

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.