-
sending failed
#include "unixheader.h"
#include <stdio.h>
//#include <winsock.h>
#include <stdlib.h>
//#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 ????
-
Re: sending failed
asit <lipun4u@gmail.com> wrote in
news:3c1c0c2e-f3aa-4b93-8dc4-34f999bd1092@g17g2000prg.googlegroups.
com:
[color=blue]
>
> I think above program is correct...but why it shows error that
> sending failed ????
>[/color]
What specific error did perror report?
MV
--
I do not want replies; please follow-up to the group.
-
Re: sending failed
On Oct 13, 12:18 am, Martin Vuille <jpm...@yahoo.com> wrote:[color=blue]
> asit <lipu...@gmail.com> wrote innews:3c1c0c2e-f3aa-4b93-8dc4-34f999bd1092@g17g2000prg.googlegroups.
> com:
>
>
>[color=green]
> > I think above program is correct...but why it shows error that
> > sending failed ????[/color]
>
> What specific error did perror report?
>
> MV
>
> --
> I do not want replies; please follow-up to the group.[/color]
thanx buddy..I have fixed the problem..