How to connect to mail server in C
问题 I tried to make a connection to my mail server which is in local area network. The ip of mail server is 192.168.1.1. So, I tried the following program to test that. Program: #include<stdio.h> #include<stdlib.h> #include<sys/types.h> #include<sys/socket.h> #include<arpa/inet.h> int main() { struct sockaddr_in sa; struct in_addr ip; int fd=socket(AF_INET,SOCK_STREAM,0); if(inet_pton(AF_INET,"192.168.1.1",&ip)==-1){ printf("Unable to convert ip to binary\n"); perror(""); exit(1); } sa.sin_family