Logo Search packages:      
Sourcecode: camstream version File versions  Download package

void CFTPClient::ListenRead ( int  fd  )  [private, slot]

Activated when our data port is contacted.

In active mode, we (the client) wait for the FTP server to contact us for the data-transfer; we have sent the address & port with a PORT command before. A connection on a listening socket is signalled by a 'read' on that socket.

Definition at line 839 of file FTPClient.cc.

References CloseListen(), SetState(), and stTransfer.

Referenced by SetupListen().

   int i;
   struct sockaddr_in DataAddr;
   socklen_t DLen;

   // We got a new connection, hurray
   if (fd != ListenFD)

   // Now accept connection
   DLen = sizeof(DataAddr);
   i = accept(ListenFD, (struct sockaddr *)&DataAddr, &DLen);
   if (i < 0) {
     qWarning("Error: failed to accept connection: %d", -errno);
   if (ntohs(DataAddr.sin_port) != 20)
     qWarning("Got an incoming connection from an unprivilidged port (%d)\n", ntohs(DataAddr.sin_port));

   if (DataFD >= 0) {
     // Hey? That's odd...
     qWarning("Warning: got a second connection on data port from %s, port %d", inet_ntoa(DataAddr.sin_addr), DataAddr.sin_port);
     ::close(i); // drop it on the floor
     DataFD = i;
   // The listen port has fulfilled its puprose, close it now
qDebug("CFTPClient::ListenRead() Opened data fd [%d] = %s:%d.", DataFD, inet_ntoa(DataAddr.sin_addr), ntohs(DataAddr.sin_port));

Generated by  Doxygen 1.6.0   Back to index