Returns a reference to the protocol which will be used to get the URL.
+%
+% GetPath
+%
+\membersection{wxURL::GetPath}
+
+\func{wxString}{GetPath}{\void}
+
+Returns the path of the file to fetch. This path was encoded in the URL.
+
%
% GetError
%
protected:
wxSocketBase *m_o_socket;
+
+ size_t OnSysWrite(const void *buffer, size_t bufsize);
};
class WXDLLEXPORT wxSocketInputStream : public wxInputStream
protected:
wxSocketBase *m_i_socket;
+
+ size_t OnSysRead(void *buffer, size_t bufsize);
};
class WXDLLEXPORT wxSocketStream : public wxSocketInputStream,
{
DECLARE_CLASS(wxSocketBase)
#ifdef __WXMAC__
-friend void wxMacSocketOnRequestProc(void *refcon , short event) ;
+ friend void wxMacSocketOnRequestProc(void *refcon , short event) ;
+#endif
+#if defined(__WXGTK__) && defined(WXSOCK_INTERNAL)
+ friend void wxPrereadSocket(wxSocketBase *sock);
#endif
public:
{ return m_protoinfo->m_protoname; }
inline wxProtocol& GetProtocol() { return *m_protocol; }
inline wxURLError GetError() const { return m_error; }
+ inline wxString GetPath() const { return m_path; }
wxInputStream *GetInputStream();
wxYield();
/* Init */
- buf = copystring("Salut ! Salut ! Salut ! Salut Toto\n");
+ buf = copystring("Hi ! Hi ! Hi !\n");
buf2 = new char[strlen(buf)+1];
char c = 0xbe;
sock->WriteMsg(&c, 1);
wxInputFTPStream(wxFTP *ftp_clt, wxSocketBase *sock)
: wxSocketInputStream(*sock), m_ftp(ftp_clt) {}
- size_t StreamSize() { return m_ftpsize; }
+ size_t StreamSize() const { return m_ftpsize; }
virtual ~wxInputFTPStream(void)
{
if (LastError() != wxStream_NOERROR)
pos_size = m_lastResult.Index('(');
if (pos_size != wxNOT_FOUND) {
- wxString str_size = m_lastResult(pos_size, m_lastResult.Index(')'));
+ wxString str_size = m_lastResult(pos_size+1, m_lastResult.Index(')')-1);
in_stream->m_ftpsize = atoi(WXSTRINGCAST str_size);
}
return NULL;
}
+ sock->SetEventHandler(*GetNextHandler(), m_id);
+ sock->Notify(m_notifyme);
+ sock->SetNotify(m_neededreq);
+
return file_list;
}
return *this;
}
+size_t wxSocketOutputStream::OnSysWrite(const void *buffer, size_t size)
+{
+ return m_o_socket->Write((const char *)buffer, size).LastCount();
+}
+
// ---------------------------------------------------------------------------
// wxSocketInputStream
// ---------------------------------------------------------------------------
return *this;
}
+size_t wxSocketInputStream::OnSysRead(void *buffer, size_t size)
+{
+ return m_i_socket->Read((char *)buffer, size).LastCount();
+}
+
// ---------------------------------------------------------------------------
// wxSocketStream
// ---------------------------------------------------------------------------
// If we have got the whole needed buffer or if we don't want to
// wait then it returns immediately.
- if (!nbytes || (m_lcount && !(m_flags & WAITALL)) )
+ if (!nbytes || (count && !(m_flags & WAITALL)) ) {
+ m_lcount = count;
return *this;
+ }
m_lcount = 0;
WantBuffer(buffer, nbytes, EVT_READ);
// --------- wxSocketBase callback management -------------------
// --------------------------------------------------------------
+#ifdef __WXGTK__
+void wxPrereadSocket(wxSocketBase *sock)
+{
+ char tmp_buf[1024];
+ int got = 0;
+
+ do {
+ got = recv(sock->m_fd, tmp_buf, 1024, 0);
+ if (got > 0)
+ sock->CreatePushbackAfter(tmp_buf, got);
+ } while (got > 0);
+}
+#endif
+
#if defined(__WXMOTIF__) || defined(__WXXT__) || defined(__WXGTK__)
#if defined(__WXMOTIF__) || defined(__WXXT__)
static void wx_socket_read(XtPointer client, int *fid,
{
if (!(sock->NeededReq() & wxSocketBase::REQ_READ))
{
+#ifdef __WXGTK__
+ // We can't exit from the GDK main loop because it doesn't accept
+ // destroying input event while we are in a event dispatch.
+ // So we will preread socket and we put the data in the pushback.
+ wxPrereadSocket(sock);
+ // Then we set the socket as BLOCKING
+ int flag = 0;
+ ioctl(fd, FIONBIO, &flag);
+#endif
return;
}
{
char *curr_pos;
- m_unread = (char *) realloc(m_unread, m_unrd_size+size);
+ if (m_unread != NULL)
+ m_unread = (char *) realloc(m_unread, m_unrd_size+size);
+ else
+ m_unread = (char *) malloc(size);
curr_pos = m_unread + m_unrd_size;
memcpy(curr_pos, buffer, size);
// Retrieve service number
pos2 = temp_url.Find(':', TRUE);
if (pos2 != -1 && pos2 < pos) {
- m_servname = url(pos2, pos);
+ m_servname = temp_url(pos2+1, pos);
if (!m_servname.IsNumber())
return FALSE;
- pos2 = pos;
temp_url = temp_url(0, pos2);
}