how can i send/receive packets to POP3/IMAP server
-
hi, i just get frustrated about the problem, i m trying to connect with the Server using Winsock and then successfully able to send the packet usinf send() function but will not be able to receive the packet from server using recv() function. just look at my code snippet....... WSADATA wsaData; long Error; int iResult = WSAStartup(MAKEWORD(2,2), &wsaData); if (iResult != NO_ERROR) printf("Error at WSAStartup()\n"); // Create a SOCKET for connecting to server SOCKET ConnectSocket; ConnectSocket = socket(AF_INET, SOCK_STREAM, 0); if (ConnectSocket == INVALID_SOCKET) { printf("Error at socket(): %ld\n", WSAGetLastError()); WSACleanup(); return; } // The sockaddr_in structure specifies the address family, // IP address, and port of the server to be connected to. char* localIP; hostent* localHost; int portNumber = 443; localHost = gethostbyname("hostname"); localIP = inet_ntoa (*(struct in_addr *)*localHost->h_addr_list); sockaddr_in clientService; clientService.sin_family = AF_INET; clientService.sin_addr.s_addr = inet_addr(localIP); clientService.sin_port = htons(portNumber); // Connect to server. if ( connect(ConnectSocket,(SOCKADDR*)&clientService,sizeof(clientService)) == SOCKET_ERROR) { printf( "Failed to connect.\n" ); Error = WSAGetLastError(); printf("\n %ld \n",Error); WSACleanup(); return; } // strcpy(sendbuf,"a400\ws.asp"); bytesSent = send(ConnectSocket,sendbuf,strlen(sendbuf),0); printf("Bytes Sent: %ld\n", bytesSent ); bytesRecv = recv(ConnectSocket,recvbuf,bytesSent,0); if (bytesRecv <= 0) printf("\n Error : %d",WSAGetLastError()); WSACleanup();
-
hi, i just get frustrated about the problem, i m trying to connect with the Server using Winsock and then successfully able to send the packet usinf send() function but will not be able to receive the packet from server using recv() function. just look at my code snippet....... WSADATA wsaData; long Error; int iResult = WSAStartup(MAKEWORD(2,2), &wsaData); if (iResult != NO_ERROR) printf("Error at WSAStartup()\n"); // Create a SOCKET for connecting to server SOCKET ConnectSocket; ConnectSocket = socket(AF_INET, SOCK_STREAM, 0); if (ConnectSocket == INVALID_SOCKET) { printf("Error at socket(): %ld\n", WSAGetLastError()); WSACleanup(); return; } // The sockaddr_in structure specifies the address family, // IP address, and port of the server to be connected to. char* localIP; hostent* localHost; int portNumber = 443; localHost = gethostbyname("hostname"); localIP = inet_ntoa (*(struct in_addr *)*localHost->h_addr_list); sockaddr_in clientService; clientService.sin_family = AF_INET; clientService.sin_addr.s_addr = inet_addr(localIP); clientService.sin_port = htons(portNumber); // Connect to server. if ( connect(ConnectSocket,(SOCKADDR*)&clientService,sizeof(clientService)) == SOCKET_ERROR) { printf( "Failed to connect.\n" ); Error = WSAGetLastError(); printf("\n %ld \n",Error); WSACleanup(); return; } // strcpy(sendbuf,"a400\ws.asp"); bytesSent = send(ConnectSocket,sendbuf,strlen(sendbuf),0); printf("Bytes Sent: %ld\n", bytesSent ); bytesRecv = recv(ConnectSocket,recvbuf,bytesSent,0); if (bytesRecv <= 0) printf("\n Error : %d",WSAGetLastError()); WSACleanup();
Hi, i think so u need to use the particular port for that pop3 port is 110 like that. try it. Have A Nice Day Murali.M