Server System Inplementation With V-C++
Results 1 to 5 of 5

Thread: Server System Inplementation With V-C++

  1. #1
    Junior Member
    Join Date
    Jun 2003
    Posts
    8

    Server System Inplementation With V-C++

    Let's straight to the point.
    I would like to share about this :

    1). Make new project with MFC AppWizard (exe), select Dialog Based on step 2 , klik Support Windows Socket, and then Hit Finish Button.

    2). Design GUI interface by these folowing fiellds :
    Componen ID Componen Properties Point
    -------------------------------------------------------------------------------
    Main Dialog IDD_SERVER_DIALOG Caption Server
    Static_Text IDC_STATIC Caption Server Port
    Edit Box IDC_EDIT1 - -
    List Box IDC_LIST1 - -

    3). Add Varibles on class CServerDlg :
    Variable Type Variable Name Access
    ------------------------------------------------------------------------------------
    SOCKET sListen Public
    SOCKET sClient[n] Public
    Struct Sockaddr_in local Public
    Struct Sockaddr_in client Public
    int nRow Public
    int nClients Public

    4). On Class Wizard we also need add some variable :
    Control ID Variable Name Category Variable Type
    --------------------------------------------------------------------------------------------------------------
    IDC_EDIT1 m_sPort Value CString
    IDC_LIST1 m_cList Controll CListBox
    IDOK m_cStartButton Controll CButton

    5). Double click on Start Button and then put these folowing source :

    WSADATA wsd;
    CString str,m_sError;
    int iSize;
    CWaitCursor wait;

    UpdateData (TRUE);
    for (int i=0;i<10;i++)
    sClient[i]=NULL;

    if (WSAStartup (MAKEWORD(2,2), &wsd) !=0)
    {
    AfxMessageBox ("Failed to load winsock!");
    return;
    }

    sListen = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
    if (sListen == SOCKET_ERROR)
    {
    m_sError.Format(*socket() failed: &d", WSAGetLastError() );
    AfxMessageBox (m_sError);
    return;
    }
    local.sin_addr.s_addr = htonl(INADDR_ANY);
    local.sin_family = AF_INET;
    local.sin_port = htons(atoi(m_sPort));
    iSize = sizeof (local);

    if (bind(sListen, (struct sockaddr *)&local,iSize) ==SOCKET_ERROR)
    {
    m_sError.Format(*bind() failed: &d", WSAGetLastError());
    AfxMessageBox(m_sError);
    return;
    }
    nRow = 0;
    nClients = 0;
    m_cList.InsertString(nRow, "Server Online");
    listen(sListen, [n]);
    m_cStartBtn.EnableWindow(FALSE);
    AfxBeginThread(&thread, [n]);

    This application using Thread for listening client connection to Server.

    I run this on our computer at home. And try to connect on my Laptop at University, and we did it. Perhaps there is anyone here could add the source ? i would like to get any idea from AO ppl.

    -Mike

  2. #2
    Leftie Linux Lover the_JinX's Avatar
    Join Date
    Nov 2001
    Location
    Beverwijk Netherlands
    Posts
    2,534
    I get the source, and see what it does.. but your question ??

    This application using Thread for listening client connection to Server.

    I run this on our computer at home. And try to connect on my Laptop at University, and we did it. Perhaps there is anyone here could add the source ? i would like to get any idea from AO ppl.

    -Mike
    is completly unclear to me..

    I'd like to help, but then I need a genuine question....
    ASCII stupid question, get a stupid ANSI.
    When in Russia, pet a PETSCII.

    Get your ass over to SLAYRadio the best station for C64 Remixes !

  3. #3
    Junior Member
    Join Date
    Jun 2003
    Posts
    8
    Thanks Jinx for your respon. I just asked ppl in here, maybe there is someone who can add the source and could make the connection ( from PC at hom to Laptop at my University ) faster. It needs abot 1 minutes to wait the connection.
    We use dial-Up .. the question now is ? Is it normal to wait for one minutes to get connect to our laptop at my Campuss ?

    thnks

  4. #4
    Leftie Linux Lover the_JinX's Avatar
    Join Date
    Nov 2001
    Location
    Beverwijk Netherlands
    Posts
    2,534
    Nope.. It's not normal to have to wait for minutes..
    It should be as fast as hell.. (instant)

    I haven't had time to try out your source..

    could you perhaps send me (PM) the MS VC++ source and project (zip the souce folder (please remove the Debug and Release folders) and attach the ZIP)
    then I will take a closer look at it..

    <edit type=add>
    I can't seem to get the source above to work..
    and I do think I followed all your steps (using MS VC++ 6 )
    </edit>

    I don't have much experience with threading on windows systems.. But I have written some multi-threaded TCP/IP services on Linux/Unix systems (in C++) so I'll see what I can do..
    ASCII stupid question, get a stupid ANSI.
    When in Russia, pet a PETSCII.

    Get your ass over to SLAYRadio the best station for C64 Remixes !

  5. #5
    Junior Member
    Join Date
    Jun 2003
    Posts
    8
    sure .. and thats not the whole source. But thats the main source.

    This application using Thread for listening client connection to Server.
    i will contact you soon Jinx.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •