TCP program connection time out

Hi, I am new to TCP programmng and am strucked in my very first program. It compiles and runs but gives the error connection time out.

/*It is an echo server program that sends message to the given ip but does not receive anything */
/*I am getting connection time out. Why */


#include<stdio.h>
#include<arpa/inet.h>
#include<sys/socket.h>
#include<stdlib.h>
#include<unistd.h>
int main()
{
int sock;
struct sockaddr_in input;
sock=socket(PF_INET,SOCK_STREAM,IPPROTO_TCP);
input.sin_family=AF_INET;
input.sin_port=7;
input.sin_addr.s_addr=inet_addr("74.125.200.106");
int a=connect(sock,(struct sockaddr *)&input,sizeof(struct sockaddr_in));
perror("connect");
int b=send(sock,"hi",sizeof("hi"),0);
int c=close(sock);
return 0;
}
 
Top Bottom