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

C / C++ / MFC

 
GeneralRe: How to decrease the CPU usage Pin
David Crow10-Sep-07 5:22
David Crow10-Sep-07 5:22 
GeneralRe: How to decrease the CPU usage Pin
Mark Salsbery10-Sep-07 6:07
Mark Salsbery10-Sep-07 6:07 
QuestionJava Style Socket Programming in C++ Pin
maglev_tgv10-Sep-07 2:40
maglev_tgv10-Sep-07 2:40 
AnswerRe: Java Style Socket Programming in C++ Pin
baerten10-Sep-07 2:48
baerten10-Sep-07 2:48 
QuestionRe: Java Style Socket Programming in C++ Pin
maglev_tgv10-Sep-07 3:14
maglev_tgv10-Sep-07 3:14 
AnswerRe: Java Style Socket Programming in C++ Pin
baerten10-Sep-07 3:20
baerten10-Sep-07 3:20 
GeneralRe: Java Style Socket Programming in C++ Pin
maglev_tgv10-Sep-07 4:15
maglev_tgv10-Sep-07 4:15 
GeneralRe: Java Style Socket Programming in C++ Pin
baerten10-Sep-07 4:24
baerten10-Sep-07 4:24 
In sock.cpp you have the following lines :


    SOCKET theClient;
SOCKADDR_IN clientAddr;
int ssz = sizeof(struct sockaddr);
theClient = accept(m_socket,(LPSOCKADDR)&clientAddr,&ssz);
//theClient = accept(m_socket,NULL,NULL);
if (theClient == INVALID_SOCKET) {
    int nret = WSAGetLastError();
    throw CSocketException(nret, "Invalid client socket: Accept()");
}
CSocket *sockClient = new CSocket();
sockClient->SetSocket(theClient);
sockClient->SetClientAddr(clientAddr);


m_socket is the socket which listens on the given Port. So m_socket is a ListenSocket

theClient is also a Socket which will store an Incomming-Connection from a Client.
clientAddr is a structure which will be filled with information during the accept()-function.

After accept was executing, you have the IP and Port into this strucure.

At the end you see that clientAddr is stored inside the class, so you can access from out
your source code, to the CServerSocket class and get the Client-Information-Structure.

You get the IP in plain text with

char TheClientIP[16]="";
strcpy(TheClientIP,inet_ntoa(...->sin_addr));


Good luck
GeneralRe: Java Style Socket Programming in C++ Pin
maglev_tgv10-Sep-07 5:09
maglev_tgv10-Sep-07 5:09 
AnswerRe: Java Style Socket Programming in C++ [modified] Pin
maglev_tgv10-Sep-07 5:38
maglev_tgv10-Sep-07 5:38 
GeneralRe: Java Style Socket Programming in C++ Pin
baerten11-Sep-07 4:08
baerten11-Sep-07 4:08 
QuestionWriting a .html file Pin
neha.agarwal2710-Sep-07 2:22
neha.agarwal2710-Sep-07 2:22 
AnswerRe: Writing a .html file Pin
Paresh Chitte10-Sep-07 2:38
Paresh Chitte10-Sep-07 2:38 
AnswerRe: Writing a .html file Pin
Russell'10-Sep-07 2:39
Russell'10-Sep-07 2:39 
Questionfile search problem Pin
david bagaturia10-Sep-07 1:38
david bagaturia10-Sep-07 1:38 
AnswerRe: file search problem Pin
Cedric Moonen10-Sep-07 1:59
Cedric Moonen10-Sep-07 1:59 
GeneralRe: file search problem Pin
david bagaturia10-Sep-07 3:51
david bagaturia10-Sep-07 3:51 
GeneralRe: file search problem Pin
Cedric Moonen10-Sep-07 4:34
Cedric Moonen10-Sep-07 4:34 
GeneralRe: file search problem Pin
david bagaturia10-Sep-07 19:37
david bagaturia10-Sep-07 19:37 
QuestionFont & BkColor Pin
josip cagalj10-Sep-07 1:16
josip cagalj10-Sep-07 1:16 
AnswerRe: Font & BkColor Pin
Nishad S10-Sep-07 1:31
Nishad S10-Sep-07 1:31 
GeneralRe: Font & BkColor Pin
josip cagalj10-Sep-07 1:55
josip cagalj10-Sep-07 1:55 
GeneralRe: Font & BkColor Pin
Nishad S10-Sep-07 2:09
Nishad S10-Sep-07 2:09 
QuestionRe: Font & BkColor Pin
josip cagalj10-Sep-07 3:34
josip cagalj10-Sep-07 3:34 
QuestionReading data from Folder [modified] Pin
shakumar_2210-Sep-07 0:57
shakumar_2210-Sep-07 0:57 

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.