Click here to Skip to main content
15,923,051 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Linking issues Pin
valikac1-Oct-04 5:32
valikac1-Oct-04 5:32 
GeneralRe: Linking issues Pin
Anonymous2-Oct-04 12:07
Anonymous2-Oct-04 12:07 
Generaltemplate as a friend? (Expert question:) Pin
Boniolopez1-Oct-04 3:59
Boniolopez1-Oct-04 3:59 
GeneralRe: template as a friend? (Expert question:) Pin
valikac1-Oct-04 5:36
valikac1-Oct-04 5:36 
Generalany borland helpers Pin
porac691-Oct-04 2:47
porac691-Oct-04 2:47 
GeneralRe: any borland helpers Pin
Antony M Kancidrowski1-Oct-04 4:51
Antony M Kancidrowski1-Oct-04 4:51 
GeneralRe: any borland helpers Pin
porac691-Oct-04 5:24
porac691-Oct-04 5:24 
GeneralRe: any borland helpers Pin
David Crow1-Oct-04 5:49
David Crow1-Oct-04 5:49 
porac69 wrote:
1st: who told you thet i was in a programming course?

You were asking a programming question in a programming forum. It would be easy to assume you are therefore in a programming course.

porac69 wrote:
i am not asking for someone to write code for me, i just want some advice so if you are too good to help, MIND YOUR OWN BUSINESS!

"Please do my homework for me" type requests show up here at least once per week, especially as semesters come to an end. Don't take offense to Antony's comment as it is well-founded. While yours is not the worst by far, students do come here and type in their assignments verbatim and expect to get help.

My first question would by why is using Borland C++ a requirement?

Second, how much help are you expecting to receive from a forum devoted to Microsoft Visual C++? That's not to imply that you won't get help, but just that your chances are less, compared to the help you'd receive from a forum devoted to Borland C++. Make sense?

I put together a very simple server application that listens on port 13. When it gets a request, it sends some text back to the client. I've removed the error checking for brevity.

void main( void )
{
    WSADATA wsaData;
    int rVal;
    char Str[32];
    SOCKET client;
 
    WSAStartup(MAKEWORD(1,1), &wsaData);
 
    //create socket
    SOCKET s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
 
    //fill in sockaddr_in struct 
    SOCKADDR_IN sin, clientaddr;
    sin.sin_family = PF_INET;
    sin.sin_port = htons(13);
    sin.sin_addr.s_addr = INADDR_ANY;
 
    //bind the socket
    rVal = bind(s, (LPSOCKADDR) &sin, sizeof(sin));
 
    //get socket to listen 
    rVal = listen(s, 2);
 
    while (1)
    {
        int addrlen = sizeof(clientaddr);
 
        //wait for a client
        client = accept(s, (struct sockaddr *) &clientaddr, &addrlen);
 
        if (client < 0)
            continue;
 
        char *clienthost = inet_ntoa(clientaddr.sin_addr);
        int port = ntohs(clientaddr.sin_port);
 
        fprintf(stderr, "Received request from [%s] on port [%d]\n", clienthost, port);
 
        sprintf(Str, "Hello %s on %d", clienthost, port);
 
        rVal = send(client, Str, lstrlen(Str), 0);
 
        closesocket(client);
 
        fprintf(stderr, "Sent %s to client\n", Str);
    }
    
    closesocket(s);
 
    WSACleanup();
}



"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen


GeneralRe: any borland helpers Pin
porac691-Oct-04 6:12
porac691-Oct-04 6:12 
GeneralRe: any borland helpers Pin
porac692-Oct-04 11:16
porac692-Oct-04 11:16 
GeneralSetting The Microphone Recording Volume Pin
jerry0davis1-Oct-04 0:46
jerry0davis1-Oct-04 0:46 
GeneralRe: Setting The Microphone Recording Volume Pin
4apai1-Oct-04 1:27
4apai1-Oct-04 1:27 
GeneralRe: Setting The Microphone Recording Volume Pin
ThatsAlok1-Oct-04 20:24
ThatsAlok1-Oct-04 20:24 
GeneralOne time password generated Pin
Rajesh_K_Sharma1-Oct-04 0:29
Rajesh_K_Sharma1-Oct-04 0:29 
GeneralRe: One time password generated Pin
4apai1-Oct-04 1:23
4apai1-Oct-04 1:23 
GeneralControl Enabled or Not Pin
Imtiaz Murtaza1-Oct-04 0:10
Imtiaz Murtaza1-Oct-04 0:10 
GeneralRe: Control Enabled or Not Pin
Mike Beckerleg1-Oct-04 0:20
Mike Beckerleg1-Oct-04 0:20 
GeneralCatch 'kill interrupt' Pin
Abebe1-Oct-04 0:03
Abebe1-Oct-04 0:03 
GeneralPassing struct in a &quot;INSERT INTO...&quot; Statement Pin
filo6530-Sep-04 23:56
filo6530-Sep-04 23:56 
GeneralRe: Passing struct in a &quot;INSERT INTO...&quot; Statement Pin
4apai1-Oct-04 0:22
4apai1-Oct-04 0:22 
GeneralRe: Passing struct in a &quot;INSERT INTO...&quot; Statement Pin
Tim Smith1-Oct-04 3:52
Tim Smith1-Oct-04 3:52 
GeneralGDI problem Pin
pdtrung30-Sep-04 22:33
pdtrung30-Sep-04 22:33 
GeneralRe: GDI problem Pin
Iain Clarke, Warrior Programmer1-Oct-04 0:09
Iain Clarke, Warrior Programmer1-Oct-04 0:09 
GeneralGDI problem...:doh: Pin
pdtrung30-Sep-04 22:25
pdtrung30-Sep-04 22:25 
Generalmemory error Pin
Jayadev MV30-Sep-04 22:25
Jayadev MV30-Sep-04 22:25 

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.