Click here to Skip to main content
15,921,905 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionATL Server Web Service on Vista / IIS 7 and VS2005 Pin
Condorito17-Jun-09 7:53
Condorito17-Jun-09 7:53 
QuestionUser detailes from Outlook Pin
kasi1417-Jun-09 6:52
kasi1417-Jun-09 6:52 
AnswerRe: User detailes from Outlook Pin
Stuart Dootson17-Jun-09 7:15
professionalStuart Dootson17-Jun-09 7:15 
Questioncoding related to mac address Pin
amitkalani117-Jun-09 5:29
amitkalani117-Jun-09 5:29 
QuestionScrollbar in CStatic derived class Pin
kk.tvm17-Jun-09 2:34
kk.tvm17-Jun-09 2:34 
QuestionRe: Scrollbar in CStatic derived class Pin
David Crow17-Jun-09 2:39
David Crow17-Jun-09 2:39 
AnswerRe: Scrollbar in CStatic derived class Pin
kk.tvm17-Jun-09 20:53
kk.tvm17-Jun-09 20:53 
GeneralRe: Scrollbar in CStatic derived class Pin
chandu00418-Jun-09 0:46
chandu00418-Jun-09 0:46 
AnswerRe: Scrollbar in CStatic derived class Pin
KarstenK17-Jun-09 2:59
mveKarstenK17-Jun-09 2:59 
Questionsocket programming using vc++ Pin
rahuljin17-Jun-09 1:35
rahuljin17-Jun-09 1:35 
AnswerRe: socket programming using vc++ Pin
Garth J Lancaster17-Jun-09 2:14
professionalGarth J Lancaster17-Jun-09 2:14 
GeneralRe: socket programming using vc++ Pin
rahuljin17-Jun-09 3:04
rahuljin17-Jun-09 3:04 
GeneralRe: socket programming using vc++ Pin
Garth J Lancaster17-Jun-09 3:08
professionalGarth J Lancaster17-Jun-09 3:08 
GeneralRe: socket programming using vc++ Pin
rahuljin17-Jun-09 5:59
rahuljin17-Jun-09 5:59 
GeneralRe: socket programming using vc++ Pin
led mike17-Jun-09 6:11
led mike17-Jun-09 6:11 
GeneralRe: socket programming using vc++ Pin
rahuljin17-Jun-09 7:57
rahuljin17-Jun-09 7:57 
GeneralRe: socket programming using vc++ Pin
Garth J Lancaster17-Jun-09 12:34
professionalGarth J Lancaster17-Jun-09 12:34 
GeneralRe: socket programming using vc++ Pin
rahuljin18-Jun-09 0:12
rahuljin18-Jun-09 0:12 
GeneralRe: socket programming using vc++ Pin
Garth J Lancaster18-Jun-09 0:52
professionalGarth J Lancaster18-Jun-09 0:52 
GeneralRe: socket programming using vc++ Pin
rahuljin18-Jun-09 1:14
rahuljin18-Jun-09 1:14 
AnswerRe: socket programming using vc++ Pin
norish17-Jun-09 2:40
norish17-Jun-09 2:40 
GeneralRe: socket programming using vc++ Pin
rahuljin17-Jun-09 3:17
rahuljin17-Jun-09 3:17 
GeneralRe: socket programming using vc++ Pin
rahuljin24-Jun-09 1:39
rahuljin24-Jun-09 1:39 
GeneralRe: socket programming using vc++ Pin
norish24-Jun-09 6:34
norish24-Jun-09 6:34 
GeneralRe: socket programming using vc++ Pin
rahuljin24-Jun-09 20:34
rahuljin24-Jun-09 20:34 
here is the member funtion ----


int getServer::getInfo() 
{    
    ifstream ifile(path);
    if(ifile)
    {
        ifile.getline(sss, 80);
        sockVersion = MAKEWORD(1, 1);
        WSAStartup(sockVersion, &wsaData);
        listeningSocket = socket
            (
            AF_INET,
            SOCK_STREAM,
            IPPROTO_TCP
            );
        
        if (listeningSocket == INVALID_SOCKET)
        {
            nret = WSAGetLastError();
            reportError(nret, "socket()");
            WSACleanup();				
            return NETWORK_ERROR;
        }

        serverInfo.sin_family = AF_INET;
        serverInfo.sin_addr.s_addr = inet_addr(sss);
        serverInfo.sin_port = htons(23571);	

        nret = bind(listeningSocket, (LPSOCKADDR)&serverInfo, sizeof(struct sockaddr));
        
        if (nret == SOCKET_ERROR)
        {
            nret = WSAGetLastError();
            reportError(nret, "bind()");
            WSACleanup();
            return NETWORK_ERROR;
        }

        nret = listen(listeningSocket, 10);	

        if (nret == SOCKET_ERROR)
        {
            nret = WSAGetLastError();
            reportError(nret, "listen()");
            WSACleanup();
            return NETWORK_ERROR;
        }

        theClient = accept
            (
            listeningSocket,
            NULL,
            NULL
            );
        
        if (theClient == INVALID_SOCKET)
        {
            nret = WSAGetLastError();
            reportError(nret, "accept()");
            WSACleanup();
            return NETWORK_ERROR;
        }
        
        byteRece = recv(theClient, st, 100, 0);
        
        if (byteRece == SOCKET_ERROR)
        {
            nret = WSAGetLastError();
            reportError(nret, "send()");
            WSACleanup();
            return NETWORK_ERROR;
        }
        
        MessageBoxA(NULL, st, "Server Status", MB_OK | MB_ICONEXCLAMATION);
        closesocket(theClient);
        closesocket(listeningSocket);
        
        WSACleanup();
        return NETWORK_OK;
    }


in ip.txt, if i put the ip --- 127.0.0.1 for same pc, it works or if i set the instruction ---


serverInfo.sin_addr.s_addr = INADDR_ANY;


if i put an ip address of other pc in the network, then bind() shows an error -- 10049. the ip is like 192.168.250.201.

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.