sending failed - Unix

This is a discussion on sending failed - Unix ; #include "unixheader.h" #include //#include #include //#pragma comment(lib,"wsock32.lib") #define PORT 13000 #define BACKLOG 1 int ser_sock, cli_sock; char in_buf[1024], out_buf[65535]; int main() { //WSADATA wsaData; struct sockaddr_in ser_add, cli_add; int sock_len; char message[100] = "comd.exe binder by Asit Dhal\n"; /*if (WSAStartup(MAKEWORD(1,1), ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: sending failed

  1. sending failed

    #include "unixheader.h"
    #include
    //#include
    #include
    //#pragma comment(lib,"wsock32.lib")
    #define PORT 13000
    #define BACKLOG 1

    int ser_sock, cli_sock;
    char in_buf[1024], out_buf[65535];
    int main()
    {
    //WSADATA wsaData;
    struct sockaddr_in ser_add, cli_add;
    int sock_len;
    char message[100] = "comd.exe binder by Asit Dhal\n";

    /*if (WSAStartup(MAKEWORD(1,1), &wsaData) != 0)
    {
    perror("WASAStartup failed\n");
    exit(EXIT_FAILURE);
    }*/
    if((ser_sock=socket(AF_INET, SOCK_STREAM, 0)) == -1)
    {
    perror("socket creation error \n");
    exit(EXIT_FAILURE);
    }

    ser_add.sin_family = AF_INET;
    ser_add.sin_port = htons(PORT);
    ser_add.sin_addr.s_addr = INADDR_ANY;

    memset(ser_add.sin_zero,0,sizeof(ser_add.sin_zero) );

    if(bind(ser_sock,(struct sockaddr*)&ser_add, sizeof(ser_add)) == -1)
    {
    perror("binding failed\n");
    exit(EXIT_FAILURE);
    }

    if(listen(ser_sock, BACKLOG) == -1)
    {
    perror("listen failed\n");
    exit(EXIT_FAILURE);
    }

    sock_len = sizeof(cli_add);
    while(1)
    {
    if(cli_sock = accept(ser_sock, (struct sockaddr*)&cli_add,
    &sock_len) == -1)
    {
    perror("accept error\n");
    continue;
    }
    printf("server got connection from : %s\n",
    inet_ntoa(cli_add.sin_addr));
    if(send(cli_sock,message,strlen(message),0) == -1)
    {
    perror("sending failed");
    }

    close(cli_sock);
    }

    close(ser_sock);
    //WSACleanup();


    return 0;
    }

    I think above program is correct...but why it shows error that sending
    failed ????

  2. Re: sending failed

    asit wrote in
    news:3c1c0c2e-f3aa-4b93-8dc4-34f999bd1092@g17g2000prg.googlegroups.
    com:


    >
    > I think above program is correct...but why it shows error that
    > sending failed ????
    >


    What specific error did perror report?

    MV

    --
    I do not want replies; please follow-up to the group.

  3. Re: sending failed

    On Oct 13, 12:18 am, Martin Vuille wrote:
    > asit wrote innews:3c1c0c2e-f3aa-4b93-8dc4-34f999bd1092@g17g2000prg.googlegroups.
    > com:
    >
    >
    >
    > > I think above program is correct...but why it shows error that
    > > sending failed ????

    >
    > What specific error did perror report?
    >
    > MV
    >
    > --
    > I do not want replies; please follow-up to the group.


    thanx buddy..I have fixed the problem..

+ Reply to Thread