]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/gsocket.cpp
Add missing include for non-PCH builds
[wxWidgets.git] / src / msw / gsocket.cpp
index 1fcf0afa6d0a2f349c1830f9bf374e2cf0728682..d72e553f288c043411cd474aa27aec94b9f97550 100644 (file)
@@ -1,6 +1,6 @@
 /* -------------------------------------------------------------------------
  * Project:     GSocket (Generic Socket)
- * Name:        gsocket.cpp
+ * Name:        src/msw/gsocket.cpp
  * Copyright:   (c) Guilhem Lavaux
  * Licence:     wxWindows Licence
  * Author:      Guillermo Rodriguez Garcia <guille@iies.es>
@@ -55,7 +55,6 @@
 
 #ifndef __GSOCKET_STANDALONE__
 #   include "wx/platform.h"
-#   include "wx/setup.h"
 #endif
 
 #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
@@ -594,6 +593,18 @@ GSocketError GSocket::Connect(GSocketStream stream)
   ioctlsocket(m_fd, FIONBIO, (u_long FAR *) &arg);
   gs_gui_functions->Enable_Events(this);
 
+  // If the reuse flag is set, use the applicable socket reuse flag
+  if (m_reusable)
+  {
+     setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&arg, sizeof(u_long));
+  }
+
+  // If a local address has been set, then we need to bind to it before calling connect
+  if (m_local && m_local->m_addr)
+  {
+    bind(m_fd, m_local->m_addr, m_local->m_len);
+  }
+
   /* Connect it to the peer address, with a timeout (see below) */
   ret = connect(m_fd, m_peer->m_addr, m_peer->m_len);
 
@@ -726,7 +737,10 @@ int GSocket::Read(char *buffer, int size)
 
   /* If the socket is blocking, wait for data (with a timeout) */
   if (Input_Timeout() == GSOCK_TIMEDOUT)
+  {
+    m_error = GSOCK_TIMEDOUT;
     return -1;
+  }
 
   /* Read the data */
   if (m_stream)
@@ -1559,4 +1573,3 @@ GSocketError GAddress_UNIX_GetPath(GAddress *address, char *WXUNUSED(path), size
 typedef void (*wxDummy)();
 
 #endif  /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
-