Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how can i send/receive packets to POP3/IMAP server

how can i send/receive packets to POP3/IMAP server

Scheduled Pinned Locked Moved C / C++ / MFC
helpsysadminquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chirag_chauhan
    wrote on last edited by
    #1

    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();

    M 1 Reply Last reply
    0
    • C chirag_chauhan

      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();

      M Offline
      M Offline
      murali_utr
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups