Re: Simple email pop3/smtp source - I get a bind error
- From: "Volodymyr M. Shcherbyna" <v_scherbina@xxxxxxxxxxxxxxx>
- Date: Mon, 19 May 2008 17:42:16 +0200
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;
}
.
- References:
- Simple email pop3/smtp source - I get a bind error
- From: Test
- Re: Simple email pop3/smtp source - I get a bind error
- From: Volodymyr M. Shcherbyna
- Re: Simple email pop3/smtp source - I get a bind error
- From: Test
- Re: Simple email pop3/smtp source - I get a bind error
- From: Volodymyr M. Shcherbyna
- Re: Simple email pop3/smtp source - I get a bind error
- From: Test
- Simple email pop3/smtp source - I get a bind error
- Prev by Date: Re: problems with WlanConnect()
- Next by Date: Re: NTP/NetRemoteTOD And a zone of time
- Previous by thread: Re: Simple email pop3/smtp source - I get a bind error
- Next by thread: Simple email pop3/smtp source - I get a bind error
- Index(es):
Relevant Pages
|