Re: Simple email pop3/smtp source - I get a bind error



Hello,

Here's the full working code cut down for brevity. I've edited it from
your
example. It works well with other connections except when trying to get
replies
from my mail server. I have "mail.whatever.fi" but it's not a real
address.

Could you please answer a few questions?

0. Is "mail.whatever.fi" maps into IP of the machine where you're tring to
run your code?
1. If the answer to question 0 is "yes", do you have other application on
your machine which bind socket to the same port/ip? (you can check it using
tcpview from sysinternals.com)
1. What are you trying to achieve by binding and listening on a
"mail.whatever.fi" ? Are you going to implement a mail server yourself?

--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
"Test" <test@.nil.invalid.com> wrote in message
news:5sbl245c37jm22vihtkqgidjs8sbau4ipg@xxxxxxxxxx
"Volodymyr M. Shcherbyna" <v_scherbina@xxxxxxxxxxxxxxx> wrote:

You still need to connect to server to trigger a "LIST" command. Take a
look
at these implementations, it might help you:

http://www.codeproject.com/KB/IP/win32_pop3.aspx
http://www.codeproject.com/KB/IP/cpop3conn.aspx

Good luck,

Here's the full working code cut down for brevity. I've edited it from
your
example. It works well with other connections except when trying to get
replies
from my mail server. I have "mail.whatever.fi" but it's not a real
address.

I am fairly new to socket programming btw.

when I took out "if (bind(..) { .. }" part I get error too.

DWORD WINAPI Thread1 (PVOID pvoid)
{
SOCKET listens;
SOCKET accepts;
struct sockaddr_in service={0};
struct hostent *h;

listens = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (listens == INVALID_SOCKET)
return 0;
service.sin_family=AF_INET;
h=gethostbyname("mail.whatever.fi");
service.sin_addr.s_addr=inet_addr(inet_ntoa(*((struct in_addr
*)h->h_addr)));
service.sin_port=htons(110);
if (bind(listens, (SOCKADDR*)&service, sizeof(service)) == SOCKET_ERROR)
{ //this error comes up, bind fails
errorexit:
closesocket(listens);
ExitThread(0) ;
return 0; //not really necessary since ExitThread does it.
}
if (listen(listens, 1 ) == SOCKET_ERROR)
goto errorexit;
while (1)
{
accepts = accept(listens, NULL, NULL);
if (accepts==INVALID_SOCKET)
{
closesocket(accepts);
goto errorexit;
}
else
{ //all good exit anyway since this is just a test for connections
closesocket(accepts);
goto errorexit;
}
}
return 0;
}


.



Relevant Pages

  • Asynchronous Socket Server data
    ... The socket server knows what type of data it expects due to the interface ... I can have 1 databuffer only for each datatype to handle multiple connections? ... int bytesRead = handler.EndReceive; ... packetIndex, bytesRead); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Ping =?ISO-8859-1?Q?kr=E1ft=E9=E9_=3F_Advice_needed_?= =?ISO-8859-1?Q?to_trace_w
    ... He has two telephone extensions leading from the master socket and his ... presume that there is a fault in his extension wiring. ... If it's twisted pair ensure that it's not been connected split pair, in other words the blue white with white blue, orange white with white orange, if you get my drift, & the connections you should use are 2&5 ...
    (uk.telecom.broadband)
  • Re: !EventConnect Problem
    ... the June roll-up is available somewhere, although there's not been the usual ... The socket is not in a listening state. ... The incoming connection queue has no room for connections. ...
    (microsoft.public.windowsce.app.development)
  • Re: !EventConnect Problem
    ... the June roll-up is available somewhere, ... The socket is not in a listening state. ... The incoming connection queue has no room for connections. ...
    (microsoft.public.windowsce.app.development)
  • Re: !EventConnect Problem
    ... you're going to have to contact MS and use one of the Platform Builder ... You'll probably want to know whether the socket is ... The socket is not in a listening state. ... The incoming connection queue has no room for connections. ...
    (microsoft.public.windowsce.app.development)