Socket connection return "Process file table overflow."
- From: Nuno <nuno.esculcas@xxxxxxxxx>
- Date: Tue, 25 Mar 2008 04:15:47 -0700 (PDT)
Hi,
I'm trying to implement a HTTPS file downloader in Linux with c++. But
I've got two problems that are:
1) I can't perform two sequential downloads with the same open
socket, the SSL_write and SSL_read functions fail in the second
download.
2) Because of the first problem, before i download any file i perform
a reconnect action (close the connection and open again everything),
but the problem is that when i try to download several files (300 for
example), sequentially, in the 20s or 30s i have the following error
"Process file table overflow." when i try to create the socket. And
only after waiting a while (five ten minutes) is when i can download
any other file without restarting the process.
I' think that my problem to both problems is cleaning process, i do
not close or is missing some cleanup operations on my socket... but i
can't seem to figure what is?!
For example to connect i perform the following actions:
Connect:
{
//open the socket
m_nSocketFD = socket(PF_INET, SOCK_STREAM, 0); /*is here that the
"Process file table overflow." is given*/
bzero(&sAddr, sizeof(sAddr));
sAddr.sin_family = AF_INET;
sAddr.sin_port = htons(n_port);
sAddr.sin_addr.s_addr = *(long*)(psHost->h_addr);
connect(m_nSocketFD, (struct sockaddr*)&sAddr, sizeof(sAddr));
//open the ssl connection
m_psSSLctx = InitCTX();
m_psSSL = SSL_new(m_psSSLctx); /* create new SSL connection
state*/
SSL_set_connect_state(m_psSSL);
SSL_set_fd(m_psSSL, m_nSocketFD); /* attach the socket
descriptor*/
SSL_set_mode(m_psSSL,SSL_MODE_AUTO_RETRY);
SSL_connect(m_psSSL);
}
To close connections i perform the following actions (i think it's
here that is missing something but i don't know what?!?)
Close:
{
X509_free(m_pcX509Cert);
SSL_shutdown(m_psSSL);
SSL_free(m_psSSL);
SSL_CTX_free(m_psSSLctx);
close(m_nSocketFD);/* close socket */
}
So the normal actions that i perform to make a download are:
DownloadFile:
{
Close
Connect
SSL_write (to send the command)
SSL_read (to read the response)
}
Thanks for the attention
Nuno
.
- Prev by Date: Alternative to glade?
- Next by Date: Re: Alternative to glade?
- Previous by thread: Alternative to glade?
- Next by thread: Trouble with getbyhostname()
- Index(es):
Relevant Pages
|