]> git.saurik.com Git - wxWidgets.git/commitdiff
rename various gsock* files to sock* (except for MSW where this will be done later)
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 28 Nov 2008 13:04:47 +0000 (13:04 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 28 Nov 2008 13:04:47 +0000 (13:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56995 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

23 files changed:
Makefile.in
build/bakefiles/files.bkl
include/wx/private/gsocket.h [deleted file]
include/wx/private/gsocketiohandler.h
include/wx/private/socket.h
include/wx/unix/gsockunx.h [deleted file]
include/wx/unix/private/sockunix.h [new file with mode: 0644]
src/common/sckaddr.cpp
src/common/socket.cpp
src/gtk/gsockgtk.cpp [deleted file]
src/gtk/sockgtk.cpp [new file with mode: 0644]
src/gtk1/gsockgtk.cpp [deleted file]
src/gtk1/sockgtk.cpp [new file with mode: 0644]
src/motif/gsockmot.cpp [deleted file]
src/motif/sockmot.cpp [new file with mode: 0644]
src/msw/gsocket.cpp
src/msw/gsockmsw.cpp
src/os2/gsockpm.cpp [deleted file]
src/os2/sockpm.cpp [new file with mode: 0644]
src/osx/core/gsockosx.cpp [deleted file]
src/osx/core/sockosx.cpp [new file with mode: 0644]
src/unix/gsocket.cpp [deleted file]
src/unix/sockunix.cpp [new file with mode: 0644]

index 465a6d237f6cfdf75e09427c46fd4d0005c41304..225c4b4b71131c9a8cdde735d887d64a8101230c 100644 (file)
@@ -444,7 +444,6 @@ ALL_BASE_HEADERS =  \
        wx/meta/movable.h \
        $(BASE_PLATFORM_HDR) \
        wx/fs_inet.h \
        wx/meta/movable.h \
        $(BASE_PLATFORM_HDR) \
        wx/fs_inet.h \
-       wx/gsocket.h \
        wx/protocol/file.h \
        wx/protocol/ftp.h \
        wx/protocol/http.h \
        wx/protocol/file.h \
        wx/protocol/ftp.h \
        wx/protocol/http.h \
@@ -454,7 +453,6 @@ ALL_BASE_HEADERS =  \
        wx/sckstrm.h \
        wx/socket.h \
        wx/url.h \
        wx/sckstrm.h \
        wx/socket.h \
        wx/url.h \
-       $(NET_PLATFORM_HDR) \
        wx/xml/xml.h \
        wx/xtixml.h
 ALL_HEADERS =  \
        wx/xml/xml.h \
        wx/xtixml.h
 ALL_HEADERS =  \
@@ -610,8 +608,6 @@ ALL_PORTS_BASE_HEADERS =  \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/mimetype.h \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/mimetype.h \
-       wx/unix/private.h \
-       wx/private/gsocketiohandler.h \
        wx/msw/apptrait.h \
        wx/msw/apptbase.h \
        wx/msw/chkconf.h \
        wx/msw/apptrait.h \
        wx/msw/apptbase.h \
        wx/msw/chkconf.h \
@@ -642,7 +638,6 @@ ALL_PORTS_BASE_HEADERS =  \
        wx/palmos/stdpaths.h \
        wx/msdos/mimetype.h \
        wx/fs_inet.h \
        wx/palmos/stdpaths.h \
        wx/msdos/mimetype.h \
        wx/fs_inet.h \
-       wx/gsocket.h \
        wx/protocol/file.h \
        wx/protocol/ftp.h \
        wx/protocol/http.h \
        wx/protocol/file.h \
        wx/protocol/ftp.h \
        wx/protocol/http.h \
@@ -652,11 +647,6 @@ ALL_PORTS_BASE_HEADERS =  \
        wx/sckstrm.h \
        wx/socket.h \
        wx/url.h \
        wx/sckstrm.h \
        wx/socket.h \
        wx/url.h \
-       wx/unix/gsockunx.h \
-       wx/msw/gsockmsw.h \
-       $(NET_WINCE_HDR) \
-       wx/unix/gsockunx.h \
-       wx/unix/gsockunx.h \
        wx/xml/xml.h \
        wx/xtixml.h
 ALL_BASE_SOURCES =  \
        wx/xml/xml.h \
        wx/xtixml.h
 ALL_BASE_SOURCES =  \
@@ -815,8 +805,8 @@ ALL_BASE_SOURCES =  \
        src/common/sckstrm.cpp \
        src/common/socket.cpp \
        src/common/url.cpp \
        src/common/sckstrm.cpp \
        src/common/socket.cpp \
        src/common/url.cpp \
-       src/unix/gsocket.cpp \
-       src/osx/core/gsockosx.cpp \
+       src/unix/sockunix.cpp \
+       src/osx/core/sockosx.cpp \
        src/msw/gsocket.cpp \
        src/msw/gsockmsw.cpp \
        src/msw/urlmsw.cpp \
        src/msw/gsocket.cpp \
        src/msw/gsockmsw.cpp \
        src/msw/urlmsw.cpp \
@@ -1930,7 +1920,6 @@ COND_USE_STC_1___wxscintilla___depname = \
 @COND_TOOLKIT_WINCE@BASE_WINCE_HDR = wx/msw/wince/time.h \
 @COND_TOOLKIT_WINCE@   wx/msw/wince/chkconf.h
 @COND_TOOLKIT_WINCE@NET_WINCE_SRC = src/msw/wince/net.cpp
 @COND_TOOLKIT_WINCE@BASE_WINCE_HDR = wx/msw/wince/time.h \
 @COND_TOOLKIT_WINCE@   wx/msw/wince/chkconf.h
 @COND_TOOLKIT_WINCE@NET_WINCE_SRC = src/msw/wince/net.cpp
-@COND_TOOLKIT_WINCE@NET_WINCE_HDR = wx/msw/wince/net.h
 @COND_TOOLKIT_MSW@MSW_HTML_HDR = wx/msw/helpbest.h
 @COND_TOOLKIT_COCOA@OPENGL_HDR_PLATFORM = wx/cocoa/glcanvas.h
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_@OPENGL_HDR_PLATFORM \
 @COND_TOOLKIT_MSW@MSW_HTML_HDR = wx/msw/helpbest.h
 @COND_TOOLKIT_COCOA@OPENGL_HDR_PLATFORM = wx/cocoa/glcanvas.h
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_@OPENGL_HDR_PLATFORM \
@@ -2097,7 +2086,6 @@ COND_TOOLKIT__BASE_OSX_HDR =  \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/mimetype.h \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/mimetype.h \
-       wx/unix/private.h \
        wx/osx/core/cfdataref.h \
        wx/osx/core/cfref.h \
        wx/osx/core/cfstring.h \
        wx/osx/core/cfdataref.h \
        wx/osx/core/cfref.h \
        wx/osx/core/cfstring.h \
@@ -2120,7 +2108,6 @@ COND_TOOLKIT_COCOA_BASE_OSX_HDR =  \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/mimetype.h \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/mimetype.h \
-       wx/unix/private.h \
        wx/osx/core/cfdataref.h \
        wx/osx/core/cfref.h \
        wx/osx/core/cfstring.h \
        wx/osx/core/cfdataref.h \
        wx/osx/core/cfref.h \
        wx/osx/core/cfstring.h \
@@ -2143,7 +2130,6 @@ COND_TOOLKIT_GTK_BASE_OSX_HDR =  \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/mimetype.h \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/mimetype.h \
-       wx/unix/private.h \
        wx/osx/core/cfdataref.h \
        wx/osx/core/cfref.h \
        wx/osx/core/cfstring.h \
        wx/osx/core/cfdataref.h \
        wx/osx/core/cfref.h \
        wx/osx/core/cfstring.h \
@@ -2166,7 +2152,6 @@ COND_TOOLKIT_MOTIF_BASE_OSX_HDR =  \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/mimetype.h \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/mimetype.h \
-       wx/unix/private.h \
        wx/osx/core/cfdataref.h \
        wx/osx/core/cfref.h \
        wx/osx/core/cfstring.h \
        wx/osx/core/cfdataref.h \
        wx/osx/core/cfref.h \
        wx/osx/core/cfstring.h \
@@ -2229,7 +2214,6 @@ COND_TOOLKIT_X11_BASE_OSX_HDR =  \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/mimetype.h \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/mimetype.h \
-       wx/unix/private.h \
        wx/osx/core/cfdataref.h \
        wx/osx/core/cfref.h \
        wx/osx/core/cfstring.h \
        wx/osx/core/cfdataref.h \
        wx/osx/core/cfref.h \
        wx/osx/core/cfstring.h \
@@ -2241,9 +2225,6 @@ COND_TOOLKIT_X11_BASE_OSX_HDR =  \
 @COND_PLATFORM_MACOSX_1@BASE_PLATFORM_HDR = $(BASE_OSX_HDR)
 @COND_PLATFORM_MSDOS_1@BASE_PLATFORM_HDR = wx/msdos/mimetype.h
 COND_PLATFORM_OS2_1_BASE_PLATFORM_HDR =  \
 @COND_PLATFORM_MACOSX_1@BASE_PLATFORM_HDR = $(BASE_OSX_HDR)
 @COND_PLATFORM_MSDOS_1@BASE_PLATFORM_HDR = wx/msdos/mimetype.h
 COND_PLATFORM_OS2_1_BASE_PLATFORM_HDR =  \
-       wx/private/fdiodispatcher.h \
-       wx/private/selectdispatcher.h \
-       wx/private/gsocketiohandler.h \
        wx/unix/app.h \
        wx/os2/apptbase.h \
        wx/os2/apptrait.h \
        wx/unix/app.h \
        wx/os2/apptbase.h \
        wx/os2/apptrait.h \
@@ -2267,9 +2248,7 @@ COND_PLATFORM_UNIX_1_BASE_PLATFORM_HDR =  \
        wx/unix/stackwalk.h \
        wx/unix/tls.h \
        wx/unix/execute.h \
        wx/unix/stackwalk.h \
        wx/unix/tls.h \
        wx/unix/execute.h \
-       wx/unix/mimetype.h \
-       wx/unix/private.h \
-       wx/private/gsocketiohandler.h
+       wx/unix/mimetype.h
 @COND_PLATFORM_UNIX_1@BASE_PLATFORM_HDR = $(COND_PLATFORM_UNIX_1_BASE_PLATFORM_HDR)
 COND_PLATFORM_WIN32_1_BASE_PLATFORM_HDR =  \
        wx/msw/apptrait.h \
 @COND_PLATFORM_UNIX_1@BASE_PLATFORM_HDR = $(COND_PLATFORM_UNIX_1_BASE_PLATFORM_HDR)
 COND_PLATFORM_WIN32_1_BASE_PLATFORM_HDR =  \
        wx/msw/apptrait.h \
@@ -2294,11 +2273,6 @@ COND_PLATFORM_WIN32_1_BASE_PLATFORM_HDR =  \
        wx/msw/wrapwin.h \
        $(BASE_WINCE_HDR)
 @COND_PLATFORM_WIN32_1@BASE_PLATFORM_HDR = $(COND_PLATFORM_WIN32_1_BASE_PLATFORM_HDR)
        wx/msw/wrapwin.h \
        $(BASE_WINCE_HDR)
 @COND_PLATFORM_WIN32_1@BASE_PLATFORM_HDR = $(COND_PLATFORM_WIN32_1_BASE_PLATFORM_HDR)
-@COND_PLATFORM_MACOSX_1@NET_PLATFORM_HDR = wx/unix/gsockunx.h
-@COND_PLATFORM_OS2_1@NET_PLATFORM_HDR = wx/unix/gsockunx.h
-@COND_PLATFORM_UNIX_1@NET_PLATFORM_HDR = wx/unix/gsockunx.h
-@COND_PLATFORM_WIN32_1@NET_PLATFORM_HDR = \
-@COND_PLATFORM_WIN32_1@        wx/msw/gsockmsw.h $(NET_WINCE_HDR)
 @COND_TOOLKIT_COCOA@LOWLEVEL_HDR = 
 COND_TOOLKIT_DFB_LOWLEVEL_HDR =  \
        wx/generic/caret.h \
 @COND_TOOLKIT_COCOA@LOWLEVEL_HDR = 
 COND_TOOLKIT_DFB_LOWLEVEL_HDR =  \
        wx/generic/caret.h \
@@ -4062,11 +4036,11 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS =  \
 @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS \
 @COND_TOOLKIT_OSX_COCOA@       = monodll_osx_cocoa_utils.o
 @COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS \
 @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS \
 @COND_TOOLKIT_OSX_COCOA@       = monodll_osx_cocoa_utils.o
 @COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS \
-@COND_PLATFORM_MACOSX_1@       = monodll_unix_gsocket.o monodll_gsockosx.o
-@COND_PLATFORM_OS2_1@__NET_PLATFORM_SRC_OBJECTS = monodll_unix_gsocket.o
-@COND_PLATFORM_UNIX_1@__NET_PLATFORM_SRC_OBJECTS = monodll_unix_gsocket.o
+@COND_PLATFORM_MACOSX_1@       = monodll_sockunix.o monodll_sockosx.o
+@COND_PLATFORM_OS2_1@__NET_PLATFORM_SRC_OBJECTS = monodll_sockunix.o
+@COND_PLATFORM_UNIX_1@__NET_PLATFORM_SRC_OBJECTS = monodll_sockunix.o
 COND_PLATFORM_WIN32_1___NET_PLATFORM_SRC_OBJECTS =  \
 COND_PLATFORM_WIN32_1___NET_PLATFORM_SRC_OBJECTS =  \
-       monodll_msw_gsocket.o \
+       monodll_gsocket.o \
        monodll_gsockmsw.o \
        monodll_urlmsw.o \
        $(__NET_WINCE_SRC_OBJECTS)
        monodll_gsockmsw.o \
        monodll_urlmsw.o \
        $(__NET_WINCE_SRC_OBJECTS)
@@ -4565,7 +4539,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS =  \
        monodll_gtk1_dnd.o \
        monodll_gtk1_evtloop.o \
        monodll_gtk1_font.o \
        monodll_gtk1_dnd.o \
        monodll_gtk1_evtloop.o \
        monodll_gtk1_font.o \
-       monodll_gtk1_gsockgtk.o \
+       monodll_gtk1_sockgtk.o \
        monodll_gtk1_main.o \
        monodll_gtk1_minifram.o \
        monodll_gtk1_pen.o \
        monodll_gtk1_main.o \
        monodll_gtk1_minifram.o \
        monodll_gtk1_pen.o \
@@ -4606,7 +4580,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS =  \
        monodll_gtk_evtloop.o \
        monodll_filectrl.o \
        monodll_gtk_font.o \
        monodll_gtk_evtloop.o \
        monodll_filectrl.o \
        monodll_gtk_font.o \
-       monodll_gtk_gsockgtk.o \
+       monodll_gtk_sockgtk.o \
        monodll_gtk_minifram.o \
        monodll_gtk_pen.o \
        monodll_gtk_popupwin.o \
        monodll_gtk_minifram.o \
        monodll_gtk_pen.o \
        monodll_gtk_popupwin.o \
@@ -5030,7 +5004,7 @@ COND_TOOLKIT_MOTIF___GUI_SRC_OBJECTS =  \
        monodll_motif_font.o \
        monodll_motif_frame.o \
        monodll_motif_gauge.o \
        monodll_motif_font.o \
        monodll_motif_frame.o \
        monodll_motif_gauge.o \
-       monodll_gsockmot.o \
+       monodll_sockmot.o \
        monodll_motif_icon.o \
        monodll_motif_listbox.o \
        monodll_motif_main.o \
        monodll_motif_icon.o \
        monodll_motif_listbox.o \
        monodll_motif_main.o \
@@ -5266,7 +5240,7 @@ COND_TOOLKIT_PM___GUI_SRC_OBJECTS =  \
        monodll_os2_frame.o \
        monodll_os2_gauge.o \
        monodll_os2_gdiimage.o \
        monodll_os2_frame.o \
        monodll_os2_gauge.o \
        monodll_os2_gdiimage.o \
-       monodll_gsockpm.o \
+       monodll_sockpm.o \
        monodll_os2_helpwin.o \
        monodll_os2_icon.o \
        monodll_os2_iniconf.o \
        monodll_os2_helpwin.o \
        monodll_os2_icon.o \
        monodll_os2_iniconf.o \
@@ -5431,7 +5405,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_1 =  \
        monodll_gtk1_dnd.o \
        monodll_gtk1_evtloop.o \
        monodll_gtk1_font.o \
        monodll_gtk1_dnd.o \
        monodll_gtk1_evtloop.o \
        monodll_gtk1_font.o \
-       monodll_gtk1_gsockgtk.o \
+       monodll_gtk1_sockgtk.o \
        monodll_gtk1_main.o \
        monodll_gtk1_minifram.o \
        monodll_gtk1_pen.o \
        monodll_gtk1_main.o \
        monodll_gtk1_minifram.o \
        monodll_gtk1_pen.o \
@@ -5472,7 +5446,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_1 =  \
        monodll_gtk_evtloop.o \
        monodll_filectrl.o \
        monodll_gtk_font.o \
        monodll_gtk_evtloop.o \
        monodll_filectrl.o \
        monodll_gtk_font.o \
-       monodll_gtk_gsockgtk.o \
+       monodll_gtk_sockgtk.o \
        monodll_gtk_minifram.o \
        monodll_gtk_pen.o \
        monodll_gtk_popupwin.o \
        monodll_gtk_minifram.o \
        monodll_gtk_pen.o \
        monodll_gtk_popupwin.o \
@@ -5874,11 +5848,11 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_1 =  \
 @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_1 \
 @COND_TOOLKIT_OSX_COCOA@       = monolib_osx_cocoa_utils.o
 @COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_1 \
 @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_1 \
 @COND_TOOLKIT_OSX_COCOA@       = monolib_osx_cocoa_utils.o
 @COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_1 \
-@COND_PLATFORM_MACOSX_1@       = monolib_unix_gsocket.o monolib_gsockosx.o
-@COND_PLATFORM_OS2_1@__NET_PLATFORM_SRC_OBJECTS_1 = monolib_unix_gsocket.o
-@COND_PLATFORM_UNIX_1@__NET_PLATFORM_SRC_OBJECTS_1 = monolib_unix_gsocket.o
+@COND_PLATFORM_MACOSX_1@       = monolib_sockunix.o monolib_sockosx.o
+@COND_PLATFORM_OS2_1@__NET_PLATFORM_SRC_OBJECTS_1 = monolib_sockunix.o
+@COND_PLATFORM_UNIX_1@__NET_PLATFORM_SRC_OBJECTS_1 = monolib_sockunix.o
 COND_PLATFORM_WIN32_1___NET_PLATFORM_SRC_OBJECTS_1 =  \
 COND_PLATFORM_WIN32_1___NET_PLATFORM_SRC_OBJECTS_1 =  \
-       monolib_msw_gsocket.o \
+       monolib_gsocket.o \
        monolib_gsockmsw.o \
        monolib_urlmsw.o \
        $(__NET_WINCE_SRC_OBJECTS_1)
        monolib_gsockmsw.o \
        monolib_urlmsw.o \
        $(__NET_WINCE_SRC_OBJECTS_1)
@@ -6377,7 +6351,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_2 =  \
        monolib_gtk1_dnd.o \
        monolib_gtk1_evtloop.o \
        monolib_gtk1_font.o \
        monolib_gtk1_dnd.o \
        monolib_gtk1_evtloop.o \
        monolib_gtk1_font.o \
-       monolib_gtk1_gsockgtk.o \
+       monolib_gtk1_sockgtk.o \
        monolib_gtk1_main.o \
        monolib_gtk1_minifram.o \
        monolib_gtk1_pen.o \
        monolib_gtk1_main.o \
        monolib_gtk1_minifram.o \
        monolib_gtk1_pen.o \
@@ -6418,7 +6392,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_2 =  \
        monolib_gtk_evtloop.o \
        monolib_filectrl.o \
        monolib_gtk_font.o \
        monolib_gtk_evtloop.o \
        monolib_filectrl.o \
        monolib_gtk_font.o \
-       monolib_gtk_gsockgtk.o \
+       monolib_gtk_sockgtk.o \
        monolib_gtk_minifram.o \
        monolib_gtk_pen.o \
        monolib_gtk_popupwin.o \
        monolib_gtk_minifram.o \
        monolib_gtk_pen.o \
        monolib_gtk_popupwin.o \
@@ -6842,7 +6816,7 @@ COND_TOOLKIT_MOTIF___GUI_SRC_OBJECTS_1 =  \
        monolib_motif_font.o \
        monolib_motif_frame.o \
        monolib_motif_gauge.o \
        monolib_motif_font.o \
        monolib_motif_frame.o \
        monolib_motif_gauge.o \
-       monolib_gsockmot.o \
+       monolib_sockmot.o \
        monolib_motif_icon.o \
        monolib_motif_listbox.o \
        monolib_motif_main.o \
        monolib_motif_icon.o \
        monolib_motif_listbox.o \
        monolib_motif_main.o \
@@ -7078,7 +7052,7 @@ COND_TOOLKIT_PM___GUI_SRC_OBJECTS_1 =  \
        monolib_os2_frame.o \
        monolib_os2_gauge.o \
        monolib_os2_gdiimage.o \
        monolib_os2_frame.o \
        monolib_os2_gauge.o \
        monolib_os2_gdiimage.o \
-       monolib_gsockpm.o \
+       monolib_sockpm.o \
        monolib_os2_helpwin.o \
        monolib_os2_icon.o \
        monolib_os2_iniconf.o \
        monolib_os2_helpwin.o \
        monolib_os2_icon.o \
        monolib_os2_iniconf.o \
@@ -7243,7 +7217,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_3 =  \
        monolib_gtk1_dnd.o \
        monolib_gtk1_evtloop.o \
        monolib_gtk1_font.o \
        monolib_gtk1_dnd.o \
        monolib_gtk1_evtloop.o \
        monolib_gtk1_font.o \
-       monolib_gtk1_gsockgtk.o \
+       monolib_gtk1_sockgtk.o \
        monolib_gtk1_main.o \
        monolib_gtk1_minifram.o \
        monolib_gtk1_pen.o \
        monolib_gtk1_main.o \
        monolib_gtk1_minifram.o \
        monolib_gtk1_pen.o \
@@ -7284,7 +7258,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_3 =  \
        monolib_gtk_evtloop.o \
        monolib_filectrl.o \
        monolib_gtk_font.o \
        monolib_gtk_evtloop.o \
        monolib_filectrl.o \
        monolib_gtk_font.o \
-       monolib_gtk_gsockgtk.o \
+       monolib_gtk_sockgtk.o \
        monolib_gtk_minifram.o \
        monolib_gtk_pen.o \
        monolib_gtk_popupwin.o \
        monolib_gtk_minifram.o \
        monolib_gtk_pen.o \
        monolib_gtk_popupwin.o \
@@ -7869,11 +7843,11 @@ COND_USE_SOSYMLINKS_1___netdll___so_symlinks_uninst_cmd = rm -f \
 @COND_USE_SOSYMLINKS_1@__netdll___so_symlinks_uninst_cmd = $(COND_USE_SOSYMLINKS_1___netdll___so_symlinks_uninst_cmd)
 @COND_PLATFORM_WIN32_1@__netdll___win32rc = netdll_version_rc.o
 @COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_2 \
 @COND_USE_SOSYMLINKS_1@__netdll___so_symlinks_uninst_cmd = $(COND_USE_SOSYMLINKS_1___netdll___so_symlinks_uninst_cmd)
 @COND_PLATFORM_WIN32_1@__netdll___win32rc = netdll_version_rc.o
 @COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_2 \
-@COND_PLATFORM_MACOSX_1@       = netdll_unix_gsocket.o netdll_gsockosx.o
-@COND_PLATFORM_OS2_1@__NET_PLATFORM_SRC_OBJECTS_2 = netdll_unix_gsocket.o
-@COND_PLATFORM_UNIX_1@__NET_PLATFORM_SRC_OBJECTS_2 = netdll_unix_gsocket.o
+@COND_PLATFORM_MACOSX_1@       = netdll_sockunix.o netdll_sockosx.o
+@COND_PLATFORM_OS2_1@__NET_PLATFORM_SRC_OBJECTS_2 = netdll_sockunix.o
+@COND_PLATFORM_UNIX_1@__NET_PLATFORM_SRC_OBJECTS_2 = netdll_sockunix.o
 COND_PLATFORM_WIN32_1___NET_PLATFORM_SRC_OBJECTS_2 =  \
 COND_PLATFORM_WIN32_1___NET_PLATFORM_SRC_OBJECTS_2 =  \
-       netdll_msw_gsocket.o \
+       netdll_gsocket.o \
        netdll_gsockmsw.o \
        netdll_urlmsw.o \
        $(__NET_WINCE_SRC_OBJECTS_2)
        netdll_gsockmsw.o \
        netdll_urlmsw.o \
        $(__NET_WINCE_SRC_OBJECTS_2)
@@ -7890,11 +7864,11 @@ COND_MONOLITHIC_0_SHARED_0___netlib___depname = \
 @COND_USE_PCH_1@_____pch_wxprec_netlib_wx_wxprec_h_gch___depname \
 @COND_USE_PCH_1@       = ./.pch/wxprec_netlib/wx/wxprec.h.gch
 @COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_3 \
 @COND_USE_PCH_1@_____pch_wxprec_netlib_wx_wxprec_h_gch___depname \
 @COND_USE_PCH_1@       = ./.pch/wxprec_netlib/wx/wxprec.h.gch
 @COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_3 \
-@COND_PLATFORM_MACOSX_1@       = netlib_unix_gsocket.o netlib_gsockosx.o
-@COND_PLATFORM_OS2_1@__NET_PLATFORM_SRC_OBJECTS_3 = netlib_unix_gsocket.o
-@COND_PLATFORM_UNIX_1@__NET_PLATFORM_SRC_OBJECTS_3 = netlib_unix_gsocket.o
+@COND_PLATFORM_MACOSX_1@       = netlib_sockunix.o netlib_sockosx.o
+@COND_PLATFORM_OS2_1@__NET_PLATFORM_SRC_OBJECTS_3 = netlib_sockunix.o
+@COND_PLATFORM_UNIX_1@__NET_PLATFORM_SRC_OBJECTS_3 = netlib_sockunix.o
 COND_PLATFORM_WIN32_1___NET_PLATFORM_SRC_OBJECTS_3 =  \
 COND_PLATFORM_WIN32_1___NET_PLATFORM_SRC_OBJECTS_3 =  \
-       netlib_msw_gsocket.o \
+       netlib_gsocket.o \
        netlib_gsockmsw.o \
        netlib_urlmsw.o \
        $(__NET_WINCE_SRC_OBJECTS_3)
        netlib_gsockmsw.o \
        netlib_urlmsw.o \
        $(__NET_WINCE_SRC_OBJECTS_3)
@@ -8339,7 +8313,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_4 =  \
        coredll_gtk1_dnd.o \
        coredll_gtk1_evtloop.o \
        coredll_gtk1_font.o \
        coredll_gtk1_dnd.o \
        coredll_gtk1_evtloop.o \
        coredll_gtk1_font.o \
-       coredll_gtk1_gsockgtk.o \
+       coredll_gtk1_sockgtk.o \
        coredll_gtk1_main.o \
        coredll_gtk1_minifram.o \
        coredll_gtk1_pen.o \
        coredll_gtk1_main.o \
        coredll_gtk1_minifram.o \
        coredll_gtk1_pen.o \
@@ -8380,7 +8354,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_4 =  \
        coredll_gtk_evtloop.o \
        coredll_filectrl.o \
        coredll_gtk_font.o \
        coredll_gtk_evtloop.o \
        coredll_filectrl.o \
        coredll_gtk_font.o \
-       coredll_gtk_gsockgtk.o \
+       coredll_gtk_sockgtk.o \
        coredll_gtk_minifram.o \
        coredll_gtk_pen.o \
        coredll_gtk_popupwin.o \
        coredll_gtk_minifram.o \
        coredll_gtk_pen.o \
        coredll_gtk_popupwin.o \
@@ -8804,7 +8778,7 @@ COND_TOOLKIT_MOTIF___GUI_SRC_OBJECTS_2 =  \
        coredll_motif_font.o \
        coredll_motif_frame.o \
        coredll_motif_gauge.o \
        coredll_motif_font.o \
        coredll_motif_frame.o \
        coredll_motif_gauge.o \
-       coredll_gsockmot.o \
+       coredll_sockmot.o \
        coredll_motif_icon.o \
        coredll_motif_listbox.o \
        coredll_motif_main.o \
        coredll_motif_icon.o \
        coredll_motif_listbox.o \
        coredll_motif_main.o \
@@ -9040,7 +9014,7 @@ COND_TOOLKIT_PM___GUI_SRC_OBJECTS_2 =  \
        coredll_os2_frame.o \
        coredll_os2_gauge.o \
        coredll_os2_gdiimage.o \
        coredll_os2_frame.o \
        coredll_os2_gauge.o \
        coredll_os2_gdiimage.o \
-       coredll_gsockpm.o \
+       coredll_sockpm.o \
        coredll_os2_helpwin.o \
        coredll_os2_icon.o \
        coredll_os2_iniconf.o \
        coredll_os2_helpwin.o \
        coredll_os2_icon.o \
        coredll_os2_iniconf.o \
@@ -9205,7 +9179,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_5 =  \
        coredll_gtk1_dnd.o \
        coredll_gtk1_evtloop.o \
        coredll_gtk1_font.o \
        coredll_gtk1_dnd.o \
        coredll_gtk1_evtloop.o \
        coredll_gtk1_font.o \
-       coredll_gtk1_gsockgtk.o \
+       coredll_gtk1_sockgtk.o \
        coredll_gtk1_main.o \
        coredll_gtk1_minifram.o \
        coredll_gtk1_pen.o \
        coredll_gtk1_main.o \
        coredll_gtk1_minifram.o \
        coredll_gtk1_pen.o \
@@ -9246,7 +9220,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_5 =  \
        coredll_gtk_evtloop.o \
        coredll_filectrl.o \
        coredll_gtk_font.o \
        coredll_gtk_evtloop.o \
        coredll_filectrl.o \
        coredll_gtk_font.o \
-       coredll_gtk_gsockgtk.o \
+       coredll_gtk_sockgtk.o \
        coredll_gtk_minifram.o \
        coredll_gtk_pen.o \
        coredll_gtk_popupwin.o \
        coredll_gtk_minifram.o \
        coredll_gtk_pen.o \
        coredll_gtk_popupwin.o \
@@ -9843,7 +9817,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_6 =  \
        corelib_gtk1_dnd.o \
        corelib_gtk1_evtloop.o \
        corelib_gtk1_font.o \
        corelib_gtk1_dnd.o \
        corelib_gtk1_evtloop.o \
        corelib_gtk1_font.o \
-       corelib_gtk1_gsockgtk.o \
+       corelib_gtk1_sockgtk.o \
        corelib_gtk1_main.o \
        corelib_gtk1_minifram.o \
        corelib_gtk1_pen.o \
        corelib_gtk1_main.o \
        corelib_gtk1_minifram.o \
        corelib_gtk1_pen.o \
@@ -9884,7 +9858,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_6 =  \
        corelib_gtk_evtloop.o \
        corelib_filectrl.o \
        corelib_gtk_font.o \
        corelib_gtk_evtloop.o \
        corelib_filectrl.o \
        corelib_gtk_font.o \
-       corelib_gtk_gsockgtk.o \
+       corelib_gtk_sockgtk.o \
        corelib_gtk_minifram.o \
        corelib_gtk_pen.o \
        corelib_gtk_popupwin.o \
        corelib_gtk_minifram.o \
        corelib_gtk_pen.o \
        corelib_gtk_popupwin.o \
@@ -10308,7 +10282,7 @@ COND_TOOLKIT_MOTIF___GUI_SRC_OBJECTS_3 =  \
        corelib_motif_font.o \
        corelib_motif_frame.o \
        corelib_motif_gauge.o \
        corelib_motif_font.o \
        corelib_motif_frame.o \
        corelib_motif_gauge.o \
-       corelib_gsockmot.o \
+       corelib_sockmot.o \
        corelib_motif_icon.o \
        corelib_motif_listbox.o \
        corelib_motif_main.o \
        corelib_motif_icon.o \
        corelib_motif_listbox.o \
        corelib_motif_main.o \
@@ -10544,7 +10518,7 @@ COND_TOOLKIT_PM___GUI_SRC_OBJECTS_3 =  \
        corelib_os2_frame.o \
        corelib_os2_gauge.o \
        corelib_os2_gdiimage.o \
        corelib_os2_frame.o \
        corelib_os2_gauge.o \
        corelib_os2_gdiimage.o \
-       corelib_gsockpm.o \
+       corelib_sockpm.o \
        corelib_os2_helpwin.o \
        corelib_os2_icon.o \
        corelib_os2_iniconf.o \
        corelib_os2_helpwin.o \
        corelib_os2_icon.o \
        corelib_os2_iniconf.o \
@@ -10709,7 +10683,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_7 =  \
        corelib_gtk1_dnd.o \
        corelib_gtk1_evtloop.o \
        corelib_gtk1_font.o \
        corelib_gtk1_dnd.o \
        corelib_gtk1_evtloop.o \
        corelib_gtk1_font.o \
-       corelib_gtk1_gsockgtk.o \
+       corelib_gtk1_sockgtk.o \
        corelib_gtk1_main.o \
        corelib_gtk1_minifram.o \
        corelib_gtk1_pen.o \
        corelib_gtk1_main.o \
        corelib_gtk1_minifram.o \
        corelib_gtk1_pen.o \
@@ -10750,7 +10724,7 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___LOWLEVEL_SRC_OBJECTS_7 =  \
        corelib_gtk_evtloop.o \
        corelib_filectrl.o \
        corelib_gtk_font.o \
        corelib_gtk_evtloop.o \
        corelib_filectrl.o \
        corelib_gtk_font.o \
-       corelib_gtk_gsockgtk.o \
+       corelib_gtk_sockgtk.o \
        corelib_gtk_minifram.o \
        corelib_gtk_pen.o \
        corelib_gtk_popupwin.o \
        corelib_gtk_minifram.o \
        corelib_gtk_pen.o \
        corelib_gtk_popupwin.o \
@@ -14530,7 +14504,7 @@ monodll_socket.o: $(srcdir)/src/common/socket.cpp $(MONODLL_ODEP)
 monodll_url.o: $(srcdir)/src/common/url.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/url.cpp
 
 monodll_url.o: $(srcdir)/src/common/url.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/url.cpp
 
-monodll_msw_gsocket.o: $(srcdir)/src/msw/gsocket.cpp $(MONODLL_ODEP)
+monodll_gsocket.o: $(srcdir)/src/msw/gsocket.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/gsocket.cpp
 
 monodll_gsockmsw.o: $(srcdir)/src/msw/gsockmsw.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/gsocket.cpp
 
 monodll_gsockmsw.o: $(srcdir)/src/msw/gsockmsw.cpp $(MONODLL_ODEP)
@@ -14542,8 +14516,8 @@ monodll_urlmsw.o: $(srcdir)/src/msw/urlmsw.cpp $(MONODLL_ODEP)
 monodll_net.o: $(srcdir)/src/msw/wince/net.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/wince/net.cpp
 
 monodll_net.o: $(srcdir)/src/msw/wince/net.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/wince/net.cpp
 
-monodll_gsockosx.o: $(srcdir)/src/osx/core/gsockosx.cpp $(MONODLL_ODEP)
-       $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/gsockosx.cpp
+monodll_sockosx.o: $(srcdir)/src/osx/core/sockosx.cpp $(MONODLL_ODEP)
+       $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/sockosx.cpp
 
 monodll_graphicc.o: $(srcdir)/src/generic/graphicc.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/graphicc.cpp
 
 monodll_graphicc.o: $(srcdir)/src/generic/graphicc.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/graphicc.cpp
@@ -14851,8 +14825,8 @@ monodll_motif_frame.o: $(srcdir)/src/motif/frame.cpp $(MONODLL_ODEP)
 monodll_motif_gauge.o: $(srcdir)/src/motif/gauge.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/motif/gauge.cpp
 
 monodll_motif_gauge.o: $(srcdir)/src/motif/gauge.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/motif/gauge.cpp
 
-monodll_gsockmot.o: $(srcdir)/src/motif/gsockmot.cpp $(MONODLL_ODEP)
-       $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/motif/gsockmot.cpp
+monodll_sockmot.o: $(srcdir)/src/motif/sockmot.cpp $(MONODLL_ODEP)
+       $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/motif/sockmot.cpp
 
 monodll_motif_icon.o: $(srcdir)/src/motif/icon.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/motif/icon.cpp
 
 monodll_motif_icon.o: $(srcdir)/src/motif/icon.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/motif/icon.cpp
@@ -15478,8 +15452,8 @@ monodll_os2_gauge.o: $(srcdir)/src/os2/gauge.cpp $(MONODLL_ODEP)
 monodll_os2_gdiimage.o: $(srcdir)/src/os2/gdiimage.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/os2/gdiimage.cpp
 
 monodll_os2_gdiimage.o: $(srcdir)/src/os2/gdiimage.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/os2/gdiimage.cpp
 
-monodll_gsockpm.o: $(srcdir)/src/os2/gsockpm.cpp $(MONODLL_ODEP)
-       $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/os2/gsockpm.cpp
+monodll_sockpm.o: $(srcdir)/src/os2/sockpm.cpp $(MONODLL_ODEP)
+       $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/os2/sockpm.cpp
 
 monodll_os2_helpwin.o: $(srcdir)/src/os2/helpwin.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/os2/helpwin.cpp
 
 monodll_os2_helpwin.o: $(srcdir)/src/os2/helpwin.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/os2/helpwin.cpp
@@ -16183,14 +16157,14 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP)
 @COND_PLATFORM_OS2_1@monodll_gsocketiohandler.o: $(srcdir)/src/common/gsocketiohandler.cpp $(MONODLL_ODEP)
 @COND_PLATFORM_OS2_1@  $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/gsocketiohandler.cpp
 
 @COND_PLATFORM_OS2_1@monodll_gsocketiohandler.o: $(srcdir)/src/common/gsocketiohandler.cpp $(MONODLL_ODEP)
 @COND_PLATFORM_OS2_1@  $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/gsocketiohandler.cpp
 
-@COND_PLATFORM_UNIX_1@monodll_unix_gsocket.o: $(srcdir)/src/unix/gsocket.cpp $(MONODLL_ODEP)
-@COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/unix/gsocket.cpp
+@COND_PLATFORM_UNIX_1@monodll_sockunix.o: $(srcdir)/src/unix/sockunix.cpp $(MONODLL_ODEP)
+@COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/unix/sockunix.cpp
 
 
-@COND_PLATFORM_MACOSX_1@monodll_unix_gsocket.o: $(srcdir)/src/unix/gsocket.cpp $(MONODLL_ODEP)
-@COND_PLATFORM_MACOSX_1@       $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/unix/gsocket.cpp
+@COND_PLATFORM_MACOSX_1@monodll_sockunix.o: $(srcdir)/src/unix/sockunix.cpp $(MONODLL_ODEP)
+@COND_PLATFORM_MACOSX_1@       $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/unix/sockunix.cpp
 
 
-@COND_PLATFORM_OS2_1@monodll_unix_gsocket.o: $(srcdir)/src/unix/gsocket.cpp $(MONODLL_ODEP)
-@COND_PLATFORM_OS2_1@  $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/unix/gsocket.cpp
+@COND_PLATFORM_OS2_1@monodll_sockunix.o: $(srcdir)/src/unix/sockunix.cpp $(MONODLL_ODEP)
+@COND_PLATFORM_OS2_1@  $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/unix/sockunix.cpp
 
 @COND_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@monodll_generic_caret.o: $(srcdir)/src/generic/caret.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@   $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/caret.cpp
 
 @COND_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@monodll_generic_caret.o: $(srcdir)/src/generic/caret.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@   $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/caret.cpp
@@ -16378,8 +16352,8 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monodll_gtk_font.o: $(srcdir)/src/gtk/font.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/font.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monodll_gtk_font.o: $(srcdir)/src/gtk/font.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/font.cpp
 
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monodll_gtk_gsockgtk.o: $(srcdir)/src/gtk/gsockgtk.cpp $(MONODLL_ODEP)
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/gsockgtk.cpp
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monodll_gtk_sockgtk.o: $(srcdir)/src/gtk/sockgtk.cpp $(MONODLL_ODEP)
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/sockgtk.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monodll_gtk_minifram.o: $(srcdir)/src/gtk/minifram.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/minifram.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monodll_gtk_minifram.o: $(srcdir)/src/gtk/minifram.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/minifram.cpp
@@ -16465,8 +16439,8 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monodll_gtk1_font.o: $(srcdir)/src/gtk1/font.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk1/font.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monodll_gtk1_font.o: $(srcdir)/src/gtk1/font.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk1/font.cpp
 
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monodll_gtk1_gsockgtk.o: $(srcdir)/src/gtk1/gsockgtk.cpp $(MONODLL_ODEP)
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk1/gsockgtk.cpp
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monodll_gtk1_sockgtk.o: $(srcdir)/src/gtk1/sockgtk.cpp $(MONODLL_ODEP)
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk1/sockgtk.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monodll_gtk1_main.o: $(srcdir)/src/gtk1/main.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk1/main.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monodll_gtk1_main.o: $(srcdir)/src/gtk1/main.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk1/main.cpp
@@ -19210,7 +19184,7 @@ monolib_socket.o: $(srcdir)/src/common/socket.cpp $(MONOLIB_ODEP)
 monolib_url.o: $(srcdir)/src/common/url.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/url.cpp
 
 monolib_url.o: $(srcdir)/src/common/url.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/url.cpp
 
-monolib_msw_gsocket.o: $(srcdir)/src/msw/gsocket.cpp $(MONOLIB_ODEP)
+monolib_gsocket.o: $(srcdir)/src/msw/gsocket.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/gsocket.cpp
 
 monolib_gsockmsw.o: $(srcdir)/src/msw/gsockmsw.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/gsocket.cpp
 
 monolib_gsockmsw.o: $(srcdir)/src/msw/gsockmsw.cpp $(MONOLIB_ODEP)
@@ -19222,8 +19196,8 @@ monolib_urlmsw.o: $(srcdir)/src/msw/urlmsw.cpp $(MONOLIB_ODEP)
 monolib_net.o: $(srcdir)/src/msw/wince/net.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/wince/net.cpp
 
 monolib_net.o: $(srcdir)/src/msw/wince/net.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/wince/net.cpp
 
-monolib_gsockosx.o: $(srcdir)/src/osx/core/gsockosx.cpp $(MONOLIB_ODEP)
-       $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/gsockosx.cpp
+monolib_sockosx.o: $(srcdir)/src/osx/core/sockosx.cpp $(MONOLIB_ODEP)
+       $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/sockosx.cpp
 
 monolib_graphicc.o: $(srcdir)/src/generic/graphicc.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/graphicc.cpp
 
 monolib_graphicc.o: $(srcdir)/src/generic/graphicc.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/graphicc.cpp
@@ -19531,8 +19505,8 @@ monolib_motif_frame.o: $(srcdir)/src/motif/frame.cpp $(MONOLIB_ODEP)
 monolib_motif_gauge.o: $(srcdir)/src/motif/gauge.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/motif/gauge.cpp
 
 monolib_motif_gauge.o: $(srcdir)/src/motif/gauge.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/motif/gauge.cpp
 
-monolib_gsockmot.o: $(srcdir)/src/motif/gsockmot.cpp $(MONOLIB_ODEP)
-       $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/motif/gsockmot.cpp
+monolib_sockmot.o: $(srcdir)/src/motif/sockmot.cpp $(MONOLIB_ODEP)
+       $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/motif/sockmot.cpp
 
 monolib_motif_icon.o: $(srcdir)/src/motif/icon.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/motif/icon.cpp
 
 monolib_motif_icon.o: $(srcdir)/src/motif/icon.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/motif/icon.cpp
@@ -20158,8 +20132,8 @@ monolib_os2_gauge.o: $(srcdir)/src/os2/gauge.cpp $(MONOLIB_ODEP)
 monolib_os2_gdiimage.o: $(srcdir)/src/os2/gdiimage.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/os2/gdiimage.cpp
 
 monolib_os2_gdiimage.o: $(srcdir)/src/os2/gdiimage.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/os2/gdiimage.cpp
 
-monolib_gsockpm.o: $(srcdir)/src/os2/gsockpm.cpp $(MONOLIB_ODEP)
-       $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/os2/gsockpm.cpp
+monolib_sockpm.o: $(srcdir)/src/os2/sockpm.cpp $(MONOLIB_ODEP)
+       $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/os2/sockpm.cpp
 
 monolib_os2_helpwin.o: $(srcdir)/src/os2/helpwin.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/os2/helpwin.cpp
 
 monolib_os2_helpwin.o: $(srcdir)/src/os2/helpwin.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/os2/helpwin.cpp
@@ -20863,14 +20837,14 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP)
 @COND_PLATFORM_OS2_1@monolib_gsocketiohandler.o: $(srcdir)/src/common/gsocketiohandler.cpp $(MONOLIB_ODEP)
 @COND_PLATFORM_OS2_1@  $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/gsocketiohandler.cpp
 
 @COND_PLATFORM_OS2_1@monolib_gsocketiohandler.o: $(srcdir)/src/common/gsocketiohandler.cpp $(MONOLIB_ODEP)
 @COND_PLATFORM_OS2_1@  $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/gsocketiohandler.cpp
 
-@COND_PLATFORM_UNIX_1@monolib_unix_gsocket.o: $(srcdir)/src/unix/gsocket.cpp $(MONOLIB_ODEP)
-@COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/unix/gsocket.cpp
+@COND_PLATFORM_UNIX_1@monolib_sockunix.o: $(srcdir)/src/unix/sockunix.cpp $(MONOLIB_ODEP)
+@COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/unix/sockunix.cpp
 
 
-@COND_PLATFORM_MACOSX_1@monolib_unix_gsocket.o: $(srcdir)/src/unix/gsocket.cpp $(MONOLIB_ODEP)
-@COND_PLATFORM_MACOSX_1@       $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/unix/gsocket.cpp
+@COND_PLATFORM_MACOSX_1@monolib_sockunix.o: $(srcdir)/src/unix/sockunix.cpp $(MONOLIB_ODEP)
+@COND_PLATFORM_MACOSX_1@       $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/unix/sockunix.cpp
 
 
-@COND_PLATFORM_OS2_1@monolib_unix_gsocket.o: $(srcdir)/src/unix/gsocket.cpp $(MONOLIB_ODEP)
-@COND_PLATFORM_OS2_1@  $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/unix/gsocket.cpp
+@COND_PLATFORM_OS2_1@monolib_sockunix.o: $(srcdir)/src/unix/sockunix.cpp $(MONOLIB_ODEP)
+@COND_PLATFORM_OS2_1@  $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/unix/sockunix.cpp
 
 @COND_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@monolib_generic_caret.o: $(srcdir)/src/generic/caret.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@   $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/caret.cpp
 
 @COND_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@monolib_generic_caret.o: $(srcdir)/src/generic/caret.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@   $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/caret.cpp
@@ -21058,8 +21032,8 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monolib_gtk_font.o: $(srcdir)/src/gtk/font.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/font.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monolib_gtk_font.o: $(srcdir)/src/gtk/font.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/font.cpp
 
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monolib_gtk_gsockgtk.o: $(srcdir)/src/gtk/gsockgtk.cpp $(MONOLIB_ODEP)
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/gsockgtk.cpp
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monolib_gtk_sockgtk.o: $(srcdir)/src/gtk/sockgtk.cpp $(MONOLIB_ODEP)
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/sockgtk.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monolib_gtk_minifram.o: $(srcdir)/src/gtk/minifram.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/minifram.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@monolib_gtk_minifram.o: $(srcdir)/src/gtk/minifram.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/minifram.cpp
@@ -21145,8 +21119,8 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monolib_gtk1_font.o: $(srcdir)/src/gtk1/font.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk1/font.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monolib_gtk1_font.o: $(srcdir)/src/gtk1/font.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk1/font.cpp
 
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monolib_gtk1_gsockgtk.o: $(srcdir)/src/gtk1/gsockgtk.cpp $(MONOLIB_ODEP)
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk1/gsockgtk.cpp
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monolib_gtk1_sockgtk.o: $(srcdir)/src/gtk1/sockgtk.cpp $(MONOLIB_ODEP)
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk1/sockgtk.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monolib_gtk1_main.o: $(srcdir)/src/gtk1/main.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk1/main.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monolib_gtk1_main.o: $(srcdir)/src/gtk1/main.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk1/main.cpp
@@ -24454,7 +24428,7 @@ netdll_socket.o: $(srcdir)/src/common/socket.cpp $(NETDLL_ODEP)
 netdll_url.o: $(srcdir)/src/common/url.cpp $(NETDLL_ODEP)
        $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/common/url.cpp
 
 netdll_url.o: $(srcdir)/src/common/url.cpp $(NETDLL_ODEP)
        $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/common/url.cpp
 
-netdll_msw_gsocket.o: $(srcdir)/src/msw/gsocket.cpp $(NETDLL_ODEP)
+netdll_gsocket.o: $(srcdir)/src/msw/gsocket.cpp $(NETDLL_ODEP)
        $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/msw/gsocket.cpp
 
 netdll_gsockmsw.o: $(srcdir)/src/msw/gsockmsw.cpp $(NETDLL_ODEP)
        $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/msw/gsocket.cpp
 
 netdll_gsockmsw.o: $(srcdir)/src/msw/gsockmsw.cpp $(NETDLL_ODEP)
@@ -24466,17 +24440,17 @@ netdll_urlmsw.o: $(srcdir)/src/msw/urlmsw.cpp $(NETDLL_ODEP)
 netdll_net.o: $(srcdir)/src/msw/wince/net.cpp $(NETDLL_ODEP)
        $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/msw/wince/net.cpp
 
 netdll_net.o: $(srcdir)/src/msw/wince/net.cpp $(NETDLL_ODEP)
        $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/msw/wince/net.cpp
 
-netdll_gsockosx.o: $(srcdir)/src/osx/core/gsockosx.cpp $(NETDLL_ODEP)
-       $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/osx/core/gsockosx.cpp
+netdll_sockosx.o: $(srcdir)/src/osx/core/sockosx.cpp $(NETDLL_ODEP)
+       $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/osx/core/sockosx.cpp
 
 
-@COND_PLATFORM_UNIX_1@netdll_unix_gsocket.o: $(srcdir)/src/unix/gsocket.cpp $(NETDLL_ODEP)
-@COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/unix/gsocket.cpp
+@COND_PLATFORM_UNIX_1@netdll_sockunix.o: $(srcdir)/src/unix/sockunix.cpp $(NETDLL_ODEP)
+@COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/unix/sockunix.cpp
 
 
-@COND_PLATFORM_MACOSX_1@netdll_unix_gsocket.o: $(srcdir)/src/unix/gsocket.cpp $(NETDLL_ODEP)
-@COND_PLATFORM_MACOSX_1@       $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/unix/gsocket.cpp
+@COND_PLATFORM_MACOSX_1@netdll_sockunix.o: $(srcdir)/src/unix/sockunix.cpp $(NETDLL_ODEP)
+@COND_PLATFORM_MACOSX_1@       $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/unix/sockunix.cpp
 
 
-@COND_PLATFORM_OS2_1@netdll_unix_gsocket.o: $(srcdir)/src/unix/gsocket.cpp $(NETDLL_ODEP)
-@COND_PLATFORM_OS2_1@  $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/unix/gsocket.cpp
+@COND_PLATFORM_OS2_1@netdll_sockunix.o: $(srcdir)/src/unix/sockunix.cpp $(NETDLL_ODEP)
+@COND_PLATFORM_OS2_1@  $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/unix/sockunix.cpp
 
 netlib_fs_inet.o: $(srcdir)/src/common/fs_inet.cpp $(NETLIB_ODEP)
        $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/common/fs_inet.cpp
 
 netlib_fs_inet.o: $(srcdir)/src/common/fs_inet.cpp $(NETLIB_ODEP)
        $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/common/fs_inet.cpp
@@ -24508,7 +24482,7 @@ netlib_socket.o: $(srcdir)/src/common/socket.cpp $(NETLIB_ODEP)
 netlib_url.o: $(srcdir)/src/common/url.cpp $(NETLIB_ODEP)
        $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/common/url.cpp
 
 netlib_url.o: $(srcdir)/src/common/url.cpp $(NETLIB_ODEP)
        $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/common/url.cpp
 
-netlib_msw_gsocket.o: $(srcdir)/src/msw/gsocket.cpp $(NETLIB_ODEP)
+netlib_gsocket.o: $(srcdir)/src/msw/gsocket.cpp $(NETLIB_ODEP)
        $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/msw/gsocket.cpp
 
 netlib_gsockmsw.o: $(srcdir)/src/msw/gsockmsw.cpp $(NETLIB_ODEP)
        $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/msw/gsocket.cpp
 
 netlib_gsockmsw.o: $(srcdir)/src/msw/gsockmsw.cpp $(NETLIB_ODEP)
@@ -24520,17 +24494,17 @@ netlib_urlmsw.o: $(srcdir)/src/msw/urlmsw.cpp $(NETLIB_ODEP)
 netlib_net.o: $(srcdir)/src/msw/wince/net.cpp $(NETLIB_ODEP)
        $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/msw/wince/net.cpp
 
 netlib_net.o: $(srcdir)/src/msw/wince/net.cpp $(NETLIB_ODEP)
        $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/msw/wince/net.cpp
 
-netlib_gsockosx.o: $(srcdir)/src/osx/core/gsockosx.cpp $(NETLIB_ODEP)
-       $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/osx/core/gsockosx.cpp
+netlib_sockosx.o: $(srcdir)/src/osx/core/sockosx.cpp $(NETLIB_ODEP)
+       $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/osx/core/sockosx.cpp
 
 
-@COND_PLATFORM_UNIX_1@netlib_unix_gsocket.o: $(srcdir)/src/unix/gsocket.cpp $(NETLIB_ODEP)
-@COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/unix/gsocket.cpp
+@COND_PLATFORM_UNIX_1@netlib_sockunix.o: $(srcdir)/src/unix/sockunix.cpp $(NETLIB_ODEP)
+@COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/unix/sockunix.cpp
 
 
-@COND_PLATFORM_MACOSX_1@netlib_unix_gsocket.o: $(srcdir)/src/unix/gsocket.cpp $(NETLIB_ODEP)
-@COND_PLATFORM_MACOSX_1@       $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/unix/gsocket.cpp
+@COND_PLATFORM_MACOSX_1@netlib_sockunix.o: $(srcdir)/src/unix/sockunix.cpp $(NETLIB_ODEP)
+@COND_PLATFORM_MACOSX_1@       $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/unix/sockunix.cpp
 
 
-@COND_PLATFORM_OS2_1@netlib_unix_gsocket.o: $(srcdir)/src/unix/gsocket.cpp $(NETLIB_ODEP)
-@COND_PLATFORM_OS2_1@  $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/unix/gsocket.cpp
+@COND_PLATFORM_OS2_1@netlib_sockunix.o: $(srcdir)/src/unix/sockunix.cpp $(NETLIB_ODEP)
+@COND_PLATFORM_OS2_1@  $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/unix/sockunix.cpp
 
 coredll_version_rc.o: $(srcdir)/src/msw/version.rc $(COREDLL_ODEP)
        $(WINDRES) -i$< -o$@    --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_58)  $(__EXCEPTIONS_DEFINE_p_57) $(__RTTI_DEFINE_p_57) $(__THREAD_DEFINE_p_57)   --define WXBUILDING --define WXDLLNAME=$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG) $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include $(__INC_TIFF_BUILD_p_58) $(__INC_TIFF_p_58) $(__INC_JPEG_p_58) $(__INC_PNG_p_57) $(__INC_ZLIB_p_59) $(__INC_REGEX_p_57) $(__INC_EXPAT_p_57) --define WXUSINGDLL --define WXMAKINGDLL_CORE --define wxUSE_BASE=0
 
 coredll_version_rc.o: $(srcdir)/src/msw/version.rc $(COREDLL_ODEP)
        $(WINDRES) -i$< -o$@    --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_58)  $(__EXCEPTIONS_DEFINE_p_57) $(__RTTI_DEFINE_p_57) $(__THREAD_DEFINE_p_57)   --define WXBUILDING --define WXDLLNAME=$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG) $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include $(__INC_TIFF_BUILD_p_58) $(__INC_TIFF_p_58) $(__INC_JPEG_p_58) $(__INC_PNG_p_57) $(__INC_ZLIB_p_59) $(__INC_REGEX_p_57) $(__INC_EXPAT_p_57) --define WXUSINGDLL --define WXMAKINGDLL_CORE --define wxUSE_BASE=0
@@ -24874,8 +24848,8 @@ coredll_motif_frame.o: $(srcdir)/src/motif/frame.cpp $(COREDLL_ODEP)
 coredll_motif_gauge.o: $(srcdir)/src/motif/gauge.cpp $(COREDLL_ODEP)
        $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/motif/gauge.cpp
 
 coredll_motif_gauge.o: $(srcdir)/src/motif/gauge.cpp $(COREDLL_ODEP)
        $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/motif/gauge.cpp
 
-coredll_gsockmot.o: $(srcdir)/src/motif/gsockmot.cpp $(COREDLL_ODEP)
-       $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/motif/gsockmot.cpp
+coredll_sockmot.o: $(srcdir)/src/motif/sockmot.cpp $(COREDLL_ODEP)
+       $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/motif/sockmot.cpp
 
 coredll_motif_icon.o: $(srcdir)/src/motif/icon.cpp $(COREDLL_ODEP)
        $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/motif/icon.cpp
 
 coredll_motif_icon.o: $(srcdir)/src/motif/icon.cpp $(COREDLL_ODEP)
        $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/motif/icon.cpp
@@ -25501,8 +25475,8 @@ coredll_os2_gauge.o: $(srcdir)/src/os2/gauge.cpp $(COREDLL_ODEP)
 coredll_os2_gdiimage.o: $(srcdir)/src/os2/gdiimage.cpp $(COREDLL_ODEP)
        $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/os2/gdiimage.cpp
 
 coredll_os2_gdiimage.o: $(srcdir)/src/os2/gdiimage.cpp $(COREDLL_ODEP)
        $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/os2/gdiimage.cpp
 
-coredll_gsockpm.o: $(srcdir)/src/os2/gsockpm.cpp $(COREDLL_ODEP)
-       $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/os2/gsockpm.cpp
+coredll_sockpm.o: $(srcdir)/src/os2/sockpm.cpp $(COREDLL_ODEP)
+       $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/os2/sockpm.cpp
 
 coredll_os2_helpwin.o: $(srcdir)/src/os2/helpwin.cpp $(COREDLL_ODEP)
        $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/os2/helpwin.cpp
 
 coredll_os2_helpwin.o: $(srcdir)/src/os2/helpwin.cpp $(COREDLL_ODEP)
        $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/os2/helpwin.cpp
@@ -25927,8 +25901,8 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@coredll_gtk_font.o: $(srcdir)/src/gtk/font.cpp $(COREDLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk/font.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@coredll_gtk_font.o: $(srcdir)/src/gtk/font.cpp $(COREDLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk/font.cpp
 
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@coredll_gtk_gsockgtk.o: $(srcdir)/src/gtk/gsockgtk.cpp $(COREDLL_ODEP)
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk/gsockgtk.cpp
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@coredll_gtk_sockgtk.o: $(srcdir)/src/gtk/sockgtk.cpp $(COREDLL_ODEP)
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk/sockgtk.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@coredll_gtk_minifram.o: $(srcdir)/src/gtk/minifram.cpp $(COREDLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk/minifram.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@coredll_gtk_minifram.o: $(srcdir)/src/gtk/minifram.cpp $(COREDLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk/minifram.cpp
@@ -26014,8 +25988,8 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@coredll_gtk1_font.o: $(srcdir)/src/gtk1/font.cpp $(COREDLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk1/font.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@coredll_gtk1_font.o: $(srcdir)/src/gtk1/font.cpp $(COREDLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk1/font.cpp
 
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@coredll_gtk1_gsockgtk.o: $(srcdir)/src/gtk1/gsockgtk.cpp $(COREDLL_ODEP)
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk1/gsockgtk.cpp
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@coredll_gtk1_sockgtk.o: $(srcdir)/src/gtk1/sockgtk.cpp $(COREDLL_ODEP)
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk1/sockgtk.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@coredll_gtk1_main.o: $(srcdir)/src/gtk1/main.cpp $(COREDLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk1/main.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@coredll_gtk1_main.o: $(srcdir)/src/gtk1/main.cpp $(COREDLL_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk1/main.cpp
@@ -28381,8 +28355,8 @@ corelib_motif_frame.o: $(srcdir)/src/motif/frame.cpp $(CORELIB_ODEP)
 corelib_motif_gauge.o: $(srcdir)/src/motif/gauge.cpp $(CORELIB_ODEP)
        $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/motif/gauge.cpp
 
 corelib_motif_gauge.o: $(srcdir)/src/motif/gauge.cpp $(CORELIB_ODEP)
        $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/motif/gauge.cpp
 
-corelib_gsockmot.o: $(srcdir)/src/motif/gsockmot.cpp $(CORELIB_ODEP)
-       $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/motif/gsockmot.cpp
+corelib_sockmot.o: $(srcdir)/src/motif/sockmot.cpp $(CORELIB_ODEP)
+       $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/motif/sockmot.cpp
 
 corelib_motif_icon.o: $(srcdir)/src/motif/icon.cpp $(CORELIB_ODEP)
        $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/motif/icon.cpp
 
 corelib_motif_icon.o: $(srcdir)/src/motif/icon.cpp $(CORELIB_ODEP)
        $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/motif/icon.cpp
@@ -29008,8 +28982,8 @@ corelib_os2_gauge.o: $(srcdir)/src/os2/gauge.cpp $(CORELIB_ODEP)
 corelib_os2_gdiimage.o: $(srcdir)/src/os2/gdiimage.cpp $(CORELIB_ODEP)
        $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/os2/gdiimage.cpp
 
 corelib_os2_gdiimage.o: $(srcdir)/src/os2/gdiimage.cpp $(CORELIB_ODEP)
        $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/os2/gdiimage.cpp
 
-corelib_gsockpm.o: $(srcdir)/src/os2/gsockpm.cpp $(CORELIB_ODEP)
-       $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/os2/gsockpm.cpp
+corelib_sockpm.o: $(srcdir)/src/os2/sockpm.cpp $(CORELIB_ODEP)
+       $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/os2/sockpm.cpp
 
 corelib_os2_helpwin.o: $(srcdir)/src/os2/helpwin.cpp $(CORELIB_ODEP)
        $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/os2/helpwin.cpp
 
 corelib_os2_helpwin.o: $(srcdir)/src/os2/helpwin.cpp $(CORELIB_ODEP)
        $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/os2/helpwin.cpp
@@ -29434,8 +29408,8 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@corelib_gtk_font.o: $(srcdir)/src/gtk/font.cpp $(CORELIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk/font.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@corelib_gtk_font.o: $(srcdir)/src/gtk/font.cpp $(CORELIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk/font.cpp
 
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@corelib_gtk_gsockgtk.o: $(srcdir)/src/gtk/gsockgtk.cpp $(CORELIB_ODEP)
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk/gsockgtk.cpp
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@corelib_gtk_sockgtk.o: $(srcdir)/src/gtk/sockgtk.cpp $(CORELIB_ODEP)
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk/sockgtk.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@corelib_gtk_minifram.o: $(srcdir)/src/gtk/minifram.cpp $(CORELIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk/minifram.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@corelib_gtk_minifram.o: $(srcdir)/src/gtk/minifram.cpp $(CORELIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk/minifram.cpp
@@ -29521,8 +29495,8 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@corelib_gtk1_font.o: $(srcdir)/src/gtk1/font.cpp $(CORELIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk1/font.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@corelib_gtk1_font.o: $(srcdir)/src/gtk1/font.cpp $(CORELIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk1/font.cpp
 
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@corelib_gtk1_gsockgtk.o: $(srcdir)/src/gtk1/gsockgtk.cpp $(CORELIB_ODEP)
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk1/gsockgtk.cpp
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@corelib_gtk1_sockgtk.o: $(srcdir)/src/gtk1/sockgtk.cpp $(CORELIB_ODEP)
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk1/sockgtk.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@corelib_gtk1_main.o: $(srcdir)/src/gtk1/main.cpp $(CORELIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk1/main.cpp
 
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@corelib_gtk1_main.o: $(srcdir)/src/gtk1/main.cpp $(CORELIB_ODEP)
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@  $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk1/main.cpp
index 1b394716566c58b22d37b80b879b83b6531429f8..084b1224729ddc0f5d3416a727db8f34797046bc 100644 (file)
@@ -99,7 +99,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     $(BASE_UNIX_AND_DARWIN_HDR)
     wx/unix/execute.h
     wx/unix/mimetype.h
     $(BASE_UNIX_AND_DARWIN_HDR)
     wx/unix/execute.h
     wx/unix/mimetype.h
-    wx/unix/private.h
 </set>
 
 <!--
 </set>
 
 <!--
@@ -114,7 +113,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
 </set>
 <set var="BASE_UNIX_HDR" hints="files">
     $(BASE_UNIX_AND_DARWIN_NOTWXMAC_HDR)
 </set>
 <set var="BASE_UNIX_HDR" hints="files">
     $(BASE_UNIX_AND_DARWIN_NOTWXMAC_HDR)
-    wx/private/gsocketiohandler.h
 </set>
 
 <!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -->
 </set>
 
 <!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -->
@@ -249,9 +247,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
 <set var="BASE_AND_GUI_OS2_SRC" hints="files">
 </set>
 <set var="BASE_OS2_HDR" hints="files">
 <set var="BASE_AND_GUI_OS2_SRC" hints="files">
 </set>
 <set var="BASE_OS2_HDR" hints="files">
-    wx/private/fdiodispatcher.h
-    wx/private/selectdispatcher.h
-    wx/private/gsocketiohandler.h
     wx/unix/app.h
     wx/os2/apptbase.h
     wx/os2/apptrait.h
     wx/unix/app.h
     wx/os2/apptbase.h
     wx/os2/apptrait.h
@@ -540,14 +535,11 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
 <!-- ====================================================================== -->
 
 <set var="NET_UNIX_SRC" hints="files">
 <!-- ====================================================================== -->
 
 <set var="NET_UNIX_SRC" hints="files">
-    src/unix/gsocket.cpp
-</set>
-<set var="NET_UNIX_HDR" hints="files">
-    wx/unix/gsockunx.h
+    src/unix/sockunix.cpp
 </set>
 
 <set var="NET_OSX_SRC" hints="files">
 </set>
 
 <set var="NET_OSX_SRC" hints="files">
-    src/osx/core/gsockosx.cpp
+    src/osx/core/sockosx.cpp
 </set>
 
 <set var="NET_WIN32_SRC" hints="files">
 </set>
 
 <set var="NET_WIN32_SRC" hints="files">
@@ -567,10 +559,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
 </set>
 
 <set var="NET_OS2_SRC" hints="files">
 </set>
 
 <set var="NET_OS2_SRC" hints="files">
-    src/unix/gsocket.cpp
-</set>
-<set var="NET_OS2_HDR" hints="files">
-    wx/unix/gsockunx.h
+    src/unix/sockunix.cpp
 </set>
 
 <set var="NET_CMN_SRC" hints="files">
 </set>
 
 <set var="NET_CMN_SRC" hints="files">
@@ -587,7 +576,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
 </set>
 <set var="NET_CMN_HDR" hints="files">
     wx/fs_inet.h
 </set>
 <set var="NET_CMN_HDR" hints="files">
     wx/fs_inet.h
-    wx/gsocket.h
     wx/protocol/file.h
     wx/protocol/ftp.h
     wx/protocol/http.h
     wx/protocol/file.h
     wx/protocol/ftp.h
     wx/protocol/http.h
@@ -999,7 +987,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     src/gtk/evtloop.cpp
     src/gtk/filectrl.cpp
     src/gtk/font.cpp
     src/gtk/evtloop.cpp
     src/gtk/filectrl.cpp
     src/gtk/font.cpp
-    src/gtk/gsockgtk.cpp
+    src/gtk/sockgtk.cpp
     src/gtk/minifram.cpp
     src/gtk/pen.cpp
     src/gtk/popupwin.cpp
     src/gtk/minifram.cpp
     src/gtk/pen.cpp
     src/gtk/popupwin.cpp
@@ -1183,7 +1171,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     src/gtk1/dnd.cpp
     src/gtk1/evtloop.cpp
     src/gtk1/font.cpp
     src/gtk1/dnd.cpp
     src/gtk1/evtloop.cpp
     src/gtk1/font.cpp
-    src/gtk1/gsockgtk.cpp
+    src/gtk1/sockgtk.cpp
     src/gtk1/main.cpp
     src/gtk1/minifram.cpp
     src/gtk1/pen.cpp
     src/gtk1/main.cpp
     src/gtk1/minifram.cpp
     src/gtk1/pen.cpp
@@ -1373,7 +1361,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     src/motif/font.cpp
     src/motif/frame.cpp
     src/motif/gauge.cpp
     src/motif/font.cpp
     src/motif/frame.cpp
     src/motif/gauge.cpp
-    src/motif/gsockmot.cpp
+    src/motif/sockmot.cpp
     src/motif/icon.cpp
     src/motif/listbox.cpp
     src/motif/main.cpp
     src/motif/icon.cpp
     src/motif/listbox.cpp
     src/motif/main.cpp
@@ -2034,7 +2022,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     src/os2/frame.cpp
     src/os2/gauge.cpp
     src/os2/gdiimage.cpp
     src/os2/frame.cpp
     src/os2/gauge.cpp
     src/os2/gdiimage.cpp
-    src/os2/gsockpm.cpp
+    src/os2/sockpm.cpp
     src/os2/helpwin.cpp
     src/os2/icon.cpp
     src/os2/iniconf.cpp
     src/os2/helpwin.cpp
     src/os2/icon.cpp
     src/os2/iniconf.cpp
@@ -3622,10 +3610,7 @@ src/osx/iphone/window.mm
         <if cond="PLATFORM_OS2=='1'">$(NET_OS2_SRC)</if>
     </set>
     <set var="NET_PLATFORM_HDR" hints="files">
         <if cond="PLATFORM_OS2=='1'">$(NET_OS2_SRC)</if>
     </set>
     <set var="NET_PLATFORM_HDR" hints="files">
-        <if cond="PLATFORM_UNIX=='1'">$(NET_UNIX_HDR)</if>
         <if cond="PLATFORM_WIN32=='1'">$(NET_WIN32_HDR) $(NET_WINCE_HDR)</if>
         <if cond="PLATFORM_WIN32=='1'">$(NET_WIN32_HDR) $(NET_WINCE_HDR)</if>
-        <if cond="PLATFORM_OS2=='1'">$(NET_OS2_HDR)</if>
-        <if cond="PLATFORM_MACOSX=='1'">$(NET_UNIX_HDR)</if>
     </set>
 
     <set var="NET_SRC" hints="files">
     </set>
 
     <set var="NET_SRC" hints="files">
@@ -3795,7 +3780,7 @@ src/osx/iphone/window.mm
     <!-- for 'make install', only the headers needed for the installed port -->
     <set var="ALL_BASE_HEADERS" make_var="1" hints="files">
         $(BASE_CMN_HDR) $(BASE_PLATFORM_HDR)
     <!-- for 'make install', only the headers needed for the installed port -->
     <set var="ALL_BASE_HEADERS" make_var="1" hints="files">
         $(BASE_CMN_HDR) $(BASE_PLATFORM_HDR)
-        $(NET_CMN_HDR) $(NET_PLATFORM_HDR)
+        $(NET_CMN_HDR)
         $(XML_HDR)
     </set>
     <set var="ALL_HEADERS" make_var="1" hints="files">
         $(XML_HDR)
     </set>
     <set var="ALL_HEADERS" make_var="1" hints="files">
@@ -3812,10 +3797,6 @@ src/osx/iphone/window.mm
         $(BASE_PALMOS_HDR)
         $(BASE_MSDOS_HDR)
         $(NET_CMN_HDR)
         $(BASE_PALMOS_HDR)
         $(BASE_MSDOS_HDR)
         $(NET_CMN_HDR)
-        $(NET_UNIX_HDR)
-        $(NET_WIN32_HDR) $(NET_WINCE_HDR)
-        $(NET_OS2_HDR)
-        $(NET_UNIX_HDR)
         $(XML_HDR)
     </set>
 
         $(XML_HDR)
     </set>
 
diff --git a/include/wx/private/gsocket.h b/include/wx/private/gsocket.h
deleted file mode 100644 (file)
index c70fab4..0000000
+++ /dev/null
@@ -1,443 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name:        wx/private/gsocket.h
-// Purpose:     wxSocketImpl nd related declarations
-// Authors:     Guilhem Lavaux, Vadim Zeitlin
-// Created:     April 1997
-// RCS-ID:      $Id$
-// Copyright:   (c) 1997 Guilhem Lavaux
-//              (c) 2008 Vadim Zeitlin
-// Licence:     wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-/*
-    Brief overview of different socket classes:
-
-    - wxSocketBase is the public class representing a socket ("Base" here
-      refers to the fact that wxSocketClient and wxSocketServer are derived
-      from it and predates the convention of using "Base" for common base
-      classes for platform-specific classes in wxWidgets) with implementation
-      common to all platforms and forwarding methods whose implementation
-      differs between platforms to wxSocketImpl which it contains.
-
-    - wxSocketImpl is actually just an abstract base class having only code
-      common to all platforms, the concrete implementation classes derive from
-      it and are created by wxSocketManager::CreateSocket().
-
-    - Some socket operations have different implementations in console-mode and
-      GUI applications. wxSocketManager class exists to abstract this in such
-      way that console applications (using wxBase) don't depend on wxNet. An
-      object of this class is made available via wxApp and GUI applications set
-      up a different kind of global socket manager from console ones.
-
-      TODO: it looks like wxSocketManager could be eliminated by providing
-            methods for registering/unregistering sockets directly in
-            wxEventLoop.
- */
-
-#ifndef _WX_PRIVATE_GSOCKET_H_
-#define _WX_PRIVATE_GSOCKET_H_
-
-#include "wx/defs.h"
-
-#if wxUSE_SOCKETS
-
-#include "wx/socket.h"
-
-#include <stddef.h>
-
-/*
-   Including sys/types.h under Cygwin results in the warnings about "fd_set
-   having been defined in sys/types.h" when winsock.h is included later and
-   doesn't seem to be necessary anyhow. It's not needed under Mac neither.
- */
-#if !defined(__WXMAC__) && !defined(__CYGWIN__) && !defined(__WXWINCE__)
-#include <sys/types.h>
-#endif
-
-#ifdef __WXWINCE__
-#include <stdlib.h>
-#endif
-
-// include the header defining timeval: under Windows this struct is used only
-// with sockets so we need to include winsock.h which we do via windows.h
-#ifdef __WXMSW__
-    #include "wx/msw/wrapwin.h"
-#else
-    #include <sys/time.h>   // for timeval
-#endif
-
-// these definitions are for MSW when we don't use configure, otherwise these
-// symbols are defined by configure
-#ifndef WX_SOCKLEN_T
-    #define WX_SOCKLEN_T int
-#endif
-
-#ifndef SOCKOPTLEN_T
-    #define SOCKOPTLEN_T int
-#endif
-
-// define some symbols which winsock.h defines but traditional BSD headers
-// don't
-#ifndef SOCKET
-    #define SOCKET int
-#endif
-
-#ifndef INVALID_SOCKET
-    #define INVALID_SOCKET (-1)
-#endif
-
-#ifndef SOCKET_ERROR
-    #define SOCKET_ERROR (-1)
-#endif
-
-#if wxUSE_IPV6
-    typedef struct sockaddr_storage wxSockAddr;
-#else
-    typedef struct sockaddr wxSockAddr;
-#endif
-
-enum GAddressType
-{
-    wxSOCKET_NOFAMILY = 0,
-    wxSOCKET_INET,
-    wxSOCKET_INET6,
-    wxSOCKET_UNIX
-};
-
-typedef int wxSocketEventFlags;
-
-struct GAddress;
-class wxSocketImpl;
-
-/*
-   Class providing hooks abstracting the differences between console and GUI
-   applications for socket code.
-
-   We also have different implementations of this class for different platforms
-   allowing us to keep more things in the common code but the main reason for
-   its existence is that we want the same socket code work differently
-   depending on whether it's used from a console or a GUI program. This is
-   achieved by implementing the virtual methods of this class differently in
-   the objects returned by wxConsoleAppTraits::GetSocketManager() and the same
-   method in wxGUIAppTraits.
- */
-class wxSocketManager
-{
-public:
-    // set the manager to use, we don't take ownership of it
-    //
-    // this should be called before creating the first wxSocket object,
-    // otherwise the manager returned by wxAppTraits::GetSocketManager() will
-    // be used
-    static void Set(wxSocketManager *manager);
-
-    // return the manager to use
-    //
-    // this initializes the manager at first use
-    static wxSocketManager *Get()
-    {
-        if ( !ms_manager )
-            Init();
-
-        return ms_manager;
-    }
-
-    // called before the first wxSocket is created and should do the
-    // initializations needed in order to use the network
-    //
-    // return true if initialized successfully; if this returns false sockets
-    // can't be used at all
-    virtual bool OnInit() = 0;
-
-    // undo the initializations of OnInit()
-    virtual void OnExit() = 0;
-
-
-    // create a concrete socket implementation associated with the given
-    // wxSocket object
-    //
-    // the returned object must be deleted by the caller
-    virtual wxSocketImpl *CreateSocket(wxSocketBase& wxsocket) = 0;
-
-
-
-    // these functions enable or disable monitoring of the given socket for the
-    // specified events inside the currently running event loop (but notice
-    // that both BSD and Winsock implementations actually use socket->m_server
-    // value to determine what exactly should be monitored so it needs to be
-    // set before calling these functions)
-    virtual void Install_Callback(wxSocketImpl *socket,
-                                  wxSocketNotify event = wxSOCKET_MAX_EVENT) = 0;
-    virtual void Uninstall_Callback(wxSocketImpl *socket,
-                                    wxSocketNotify event = wxSOCKET_MAX_EVENT) = 0;
-
-    virtual ~wxSocketManager() { }
-
-private:
-    // get the manager to use if we don't have it yet
-    static void Init();
-
-    static wxSocketManager *ms_manager;
-};
-
-/*
-    Base class for all socket implementations providing functionality common to
-    BSD and Winsock sockets.
-
-    Objects of this class are not created directly but only via its static
-    Create() method which in turn forwards to wxSocketManager::CreateSocket().
- */
-class wxSocketImpl
-{
-public:
-    // static factory function: creates the low-level socket associated with
-    // the given wxSocket (and inherits its attributes such as timeout)
-    static wxSocketImpl *Create(wxSocketBase& wxsocket);
-
-    virtual ~wxSocketImpl();
-
-    // set various socket properties: all of those can only be called before
-    // creating the socket
-    void SetTimeout(unsigned long millisec);
-    void SetNonBlocking(bool non_blocking) { m_non_blocking = non_blocking; }
-    void SetReusable() { m_reusable = true; }
-    void SetBroadcast() { m_broadcast = true; }
-    void DontDoBind() { m_dobind = false; }
-    void SetInitialSocketBuffers(int recv, int send)
-    {
-        m_initialRecvBufferSize = recv;
-        m_initialSendBufferSize = send;
-    }
-
-    wxSocketError SetLocal(GAddress *address);
-    wxSocketError SetPeer(GAddress *address);
-
-    // accessors
-    // ---------
-
-    GAddress *GetLocal();
-    GAddress *GetPeer();
-
-    wxSocketError GetError() const { return m_error; }
-    bool IsOk() const { return m_error == wxSOCKET_NOERROR; }
-
-
-    // creating/closing the socket
-    // --------------------------
-
-    // notice that SetLocal() must be called before creating the socket using
-    // any of the functions below
-    //
-    // all of Create() functions return wxSOCKET_NOERROR if the operation
-    // completed successfully or one of:
-    //  wxSOCKET_INVSOCK - the socket is in use.
-    //  wxSOCKET_INVADDR - the local (server) or peer (client) address has not
-    //                     been set.
-    //  wxSOCKET_IOERR   - any other error.
-
-    // create a socket listening on the local address specified by SetLocal()
-    // (notice that DontDoBind() is ignored by this function)
-    wxSocketError CreateServer();
-
-    // create a socket connected to the peer address specified by SetPeer()
-    // (notice that DontDoBind() is ignored by this function)
-    //
-    // this function may return wxSOCKET_WOULDBLOCK in addition to the return
-    // values listed above
-    wxSocketError CreateClient();
-
-    // create (and bind unless DontDoBind() had been called) an UDP socket
-    // associated with the given local address
-    wxSocketError CreateUDP();
-
-    // may be called whether the socket was created or not, calls DoClose() if
-    // it was indeed created
-    void Close();
-
-    virtual void Shutdown();
-
-
-    // IO operations
-    // -------------
-
-    virtual int Read(char *buffer, int size) = 0;
-    virtual int Write(const char *buffer, int size) = 0;
-
-    wxSocketEventFlags Select(wxSocketEventFlags flags);
-
-    virtual wxSocketImpl *WaitConnection(wxSocketBase& wxsocket) = 0;
-
-
-    // notifications
-    // -------------
-
-    // notify m_wxsocket about the given socket event by calling its (inaptly
-    // named) OnRequest() method
-    void NotifyOnStateChange(wxSocketNotify event);
-
-    // FIXME: making these functions virtual is a hack necessary to make the
-    //        wxBase library link without requiring wxNet under Unix where
-    //        wxSocketSelectManager (part of wxBase) uses them, they don't
-    //        really need to be virtual at all
-    virtual void Detected_Read() { }
-    virtual void Detected_Write() { }
-    virtual void Notify(bool WXUNUSED(notify)) { }
-
-    // TODO: make these fields protected and provide accessors for those of
-    //       them that wxSocketBase really needs
-//protected:
-    SOCKET m_fd;
-
-    int m_initialRecvBufferSize;
-    int m_initialSendBufferSize;
-
-    GAddress *m_local;
-    GAddress *m_peer;
-    wxSocketError m_error;
-
-    bool m_non_blocking;
-    bool m_server;
-    bool m_stream;
-    bool m_establishing;
-    bool m_reusable;
-    bool m_broadcast;
-    bool m_dobind;
-
-    struct timeval m_timeout;
-
-    wxSocketEventFlags m_detected;
-
-protected:
-    wxSocketImpl(wxSocketBase& wxsocket);
-
-private:
-    // handle the given connect() return value (which may be 0 or EWOULDBLOCK
-    // or something else)
-    virtual wxSocketError DoHandleConnect(int ret) = 0;
-
-    // called by Close() if we have a valid m_fd
-    virtual void DoClose() = 0;
-
-    // put this socket into non-blocking mode and enable monitoring this socket
-    // as part of the event loop
-    virtual void UnblockAndRegisterWithEventLoop() = 0;
-
-    // check that the socket wasn't created yet and that the given address
-    // (either m_local or m_peer depending on the socket kind) is valid and
-    // set m_error and return false if this is not the case
-    bool PreCreateCheck(GAddress *addr);
-
-    // set the given socket option: this just wraps setsockopt(SOL_SOCKET)
-    int SetSocketOption(int optname, int optval)
-    {
-        // although modern Unix systems use "const void *" for the 4th
-        // parameter here, old systems and Winsock still use "const char *"
-        return setsockopt(m_fd, SOL_SOCKET, optname,
-                          reinterpret_cast<const char *>(&optval),
-                          sizeof(optval));
-    }
-
-    // set the given socket option to true value: this is an even simpler
-    // wrapper for setsockopt(SOL_SOCKET) for boolean options
-    int EnableSocketOption(int optname)
-    {
-        return SetSocketOption(optname, 1);
-    }
-
-    // apply the options to the (just created) socket and register it with the
-    // event loop by calling UnblockAndRegisterWithEventLoop()
-    void PostCreation();
-
-    // update local address after binding/connecting
-    wxSocketError UpdateLocalAddress();
-
-
-    // set in ctor and never changed except that it's reset to NULL when the
-    // socket is shut down
-    wxSocketBase *m_wxsocket;
-
-    DECLARE_NO_COPY_CLASS(wxSocketImpl)
-};
-
-#if defined(__WXMSW__)
-    #include "wx/msw/gsockmsw.h"
-#else
-    #include "wx/unix/gsockunx.h"
-#endif
-
-
-/* GAddress */
-
-// TODO: make GAddress a real class instead of this mix of C and C++
-
-// Represents a socket endpoint, i.e. -- in spite of its name -- not an address
-// but an (address, port) pair
-struct GAddress
-{
-    struct sockaddr *m_addr;
-    size_t m_len;
-
-    GAddressType m_family;
-    int m_realfamily;
-
-    wxSocketError m_error;
-};
-
-GAddress *GAddress_new();
-GAddress *GAddress_copy(GAddress *address);
-void GAddress_destroy(GAddress *address);
-
-void GAddress_SetFamily(GAddress *address, GAddressType type);
-GAddressType GAddress_GetFamily(GAddress *address);
-
-/* The use of any of the next functions will set the address family to
- * the specific one. For example if you use GAddress_INET_SetHostName,
- * address family will be implicitly set to AF_INET.
- */
-
-wxSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname);
-wxSocketError GAddress_INET_SetBroadcastAddress(GAddress *address);
-wxSocketError GAddress_INET_SetAnyAddress(GAddress *address);
-wxSocketError GAddress_INET_SetHostAddress(GAddress *address,
-                                          unsigned long hostaddr);
-wxSocketError GAddress_INET_SetPortName(GAddress *address, const char *port,
-                                       const char *protocol);
-wxSocketError GAddress_INET_SetPort(GAddress *address, unsigned short port);
-
-wxSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname,
-                                       size_t sbuf);
-unsigned long GAddress_INET_GetHostAddress(GAddress *address);
-unsigned short GAddress_INET_GetPort(GAddress *address);
-
-wxSocketError _GAddress_translate_from(GAddress *address,
-                                      struct sockaddr *addr, int len);
-wxSocketError _GAddress_translate_to  (GAddress *address,
-                                      struct sockaddr **addr, int *len);
-wxSocketError _GAddress_Init_INET(GAddress *address);
-
-#if wxUSE_IPV6
-
-wxSocketError GAddress_INET6_SetHostName(GAddress *address, const char *hostname);
-wxSocketError GAddress_INET6_SetAnyAddress(GAddress *address);
-wxSocketError GAddress_INET6_SetHostAddress(GAddress *address,
-                                          struct in6_addr hostaddr);
-wxSocketError GAddress_INET6_SetPortName(GAddress *address, const char *port,
-                                       const char *protocol);
-wxSocketError GAddress_INET6_SetPort(GAddress *address, unsigned short port);
-
-wxSocketError GAddress_INET6_GetHostName(GAddress *address, char *hostname,
-                                       size_t sbuf);
-wxSocketError GAddress_INET6_GetHostAddress(GAddress *address,struct in6_addr *hostaddr);
-unsigned short GAddress_INET6_GetPort(GAddress *address);
-
-#endif // wxUSE_IPV6
-
-// these functions are available under all platforms but only implemented under
-// Unix ones, elsewhere they just return wxSOCKET_INVADDR
-wxSocketError _GAddress_Init_UNIX(GAddress *address);
-wxSocketError GAddress_UNIX_SetPath(GAddress *address, const char *path);
-wxSocketError GAddress_UNIX_GetPath(GAddress *address, char *path, size_t sbuf);
-
-#endif /* wxUSE_SOCKETS */
-
-#endif /* _WX_PRIVATE_GSOCKET_H_ */
index 61ecbc2f7f991f33a0000f7d4757183177cc621f..5fdee62b8a6d9601089f447eafffc44f680310a8 100644 (file)
@@ -16,7 +16,7 @@
 #if wxUSE_SOCKETS && wxUSE_SELECT_DISPATCHER
 
 #include "wx/private/selectdispatcher.h"
 #if wxUSE_SOCKETS && wxUSE_SELECT_DISPATCHER
 
 #include "wx/private/selectdispatcher.h"
-#include "wx/private/gsocket.h"
+#include "wx/private/socket.h"
 
 class WXDLLIMPEXP_BASE wxSocketIOHandler : public wxFDIOHandler
 {
 
 class WXDLLIMPEXP_BASE wxSocketIOHandler : public wxFDIOHandler
 {
index 9b20bf60ccc3563e2f75bc22f3fa981ecb46bcf8..03da655036bc45d86567b60a7fa00c1bb49a9734 100644 (file)
@@ -1,16 +1,71 @@
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
 // Name:        wx/private/socket.h
 // Name:        wx/private/socket.h
-// Purpose:     various wxSocket-related private declarations
-// Author:      Vadim Zeitlin
-// Created:     2008-11-23
+// Purpose:     wxSocketImpl nd related declarations
+// Authors:     Guilhem Lavaux, Vadim Zeitlin
+// Created:     April 1997
 // RCS-ID:      $Id$
 // RCS-ID:      $Id$
-// Copyright:   (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
+// Copyright:   (c) 1997 Guilhem Lavaux
+//              (c) 2008 Vadim Zeitlin
 // Licence:     wxWindows licence
 // Licence:     wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+/*
+    Brief overview of different socket classes:
+
+    - wxSocketBase is the public class representing a socket ("Base" here
+      refers to the fact that wxSocketClient and wxSocketServer are derived
+      from it and predates the convention of using "Base" for common base
+      classes for platform-specific classes in wxWidgets) with implementation
+      common to all platforms and forwarding methods whose implementation
+      differs between platforms to wxSocketImpl which it contains.
+
+    - wxSocketImpl is actually just an abstract base class having only code
+      common to all platforms, the concrete implementation classes derive from
+      it and are created by wxSocketManager::CreateSocket().
+
+    - Some socket operations have different implementations in console-mode and
+      GUI applications. wxSocketManager class exists to abstract this in such
+      way that console applications (using wxBase) don't depend on wxNet. An
+      object of this class is made available via wxApp and GUI applications set
+      up a different kind of global socket manager from console ones.
+
+      TODO: it looks like wxSocketManager could be eliminated by providing
+            methods for registering/unregistering sockets directly in
+            wxEventLoop.
+ */
 
 #ifndef _WX_PRIVATE_SOCKET_H_
 #define _WX_PRIVATE_SOCKET_H_
 
 
 #ifndef _WX_PRIVATE_SOCKET_H_
 #define _WX_PRIVATE_SOCKET_H_
 
+#include "wx/defs.h"
+
+#if wxUSE_SOCKETS
+
+#include "wx/socket.h"
+
+#include <stddef.h>
+
+/*
+   Including sys/types.h under Cygwin results in the warnings about "fd_set
+   having been defined in sys/types.h" when winsock.h is included later and
+   doesn't seem to be necessary anyhow. It's not needed under Mac neither.
+ */
+#if !defined(__WXMAC__) && !defined(__CYGWIN__) && !defined(__WXWINCE__)
+#include <sys/types.h>
+#endif
+
+#ifdef __WXWINCE__
+#include <stdlib.h>
+#endif
+
+// include the header defining timeval: under Windows this struct is used only
+// with sockets so we need to include winsock.h which we do via windows.h
+#ifdef __WXMSW__
+    #include "wx/msw/wrapwin.h"
+#else
+    #include <sys/time.h>   // for timeval
+#endif
+
 // these definitions are for MSW when we don't use configure, otherwise these
 // symbols are defined by configure
 #ifndef WX_SOCKLEN_T
 // these definitions are for MSW when we don't use configure, otherwise these
 // symbols are defined by configure
 #ifndef WX_SOCKLEN_T
 
 // define some symbols which winsock.h defines but traditional BSD headers
 // don't
 
 // define some symbols which winsock.h defines but traditional BSD headers
 // don't
+#ifndef SOCKET
+    #define SOCKET int
+#endif
+
 #ifndef INVALID_SOCKET
     #define INVALID_SOCKET (-1)
 #endif
 #ifndef INVALID_SOCKET
     #define INVALID_SOCKET (-1)
 #endif
     typedef struct sockaddr wxSockAddr;
 #endif
 
     typedef struct sockaddr wxSockAddr;
 #endif
 
-#endif // _WX_PRIVATE_SOCKET_H_
+enum GAddressType
+{
+    wxSOCKET_NOFAMILY = 0,
+    wxSOCKET_INET,
+    wxSOCKET_INET6,
+    wxSOCKET_UNIX
+};
+
+typedef int wxSocketEventFlags;
+
+struct GAddress;
+class wxSocketImpl;
+
+/*
+   Class providing hooks abstracting the differences between console and GUI
+   applications for socket code.
+
+   We also have different implementations of this class for different platforms
+   allowing us to keep more things in the common code but the main reason for
+   its existence is that we want the same socket code work differently
+   depending on whether it's used from a console or a GUI program. This is
+   achieved by implementing the virtual methods of this class differently in
+   the objects returned by wxConsoleAppTraits::GetSocketManager() and the same
+   method in wxGUIAppTraits.
+ */
+class wxSocketManager
+{
+public:
+    // set the manager to use, we don't take ownership of it
+    //
+    // this should be called before creating the first wxSocket object,
+    // otherwise the manager returned by wxAppTraits::GetSocketManager() will
+    // be used
+    static void Set(wxSocketManager *manager);
+
+    // return the manager to use
+    //
+    // this initializes the manager at first use
+    static wxSocketManager *Get()
+    {
+        if ( !ms_manager )
+            Init();
+
+        return ms_manager;
+    }
+
+    // called before the first wxSocket is created and should do the
+    // initializations needed in order to use the network
+    //
+    // return true if initialized successfully; if this returns false sockets
+    // can't be used at all
+    virtual bool OnInit() = 0;
+
+    // undo the initializations of OnInit()
+    virtual void OnExit() = 0;
+
+
+    // create a concrete socket implementation associated with the given
+    // wxSocket object
+    //
+    // the returned object must be deleted by the caller
+    virtual wxSocketImpl *CreateSocket(wxSocketBase& wxsocket) = 0;
+
+
+
+    // these functions enable or disable monitoring of the given socket for the
+    // specified events inside the currently running event loop (but notice
+    // that both BSD and Winsock implementations actually use socket->m_server
+    // value to determine what exactly should be monitored so it needs to be
+    // set before calling these functions)
+    virtual void Install_Callback(wxSocketImpl *socket,
+                                  wxSocketNotify event = wxSOCKET_MAX_EVENT) = 0;
+    virtual void Uninstall_Callback(wxSocketImpl *socket,
+                                    wxSocketNotify event = wxSOCKET_MAX_EVENT) = 0;
+
+    virtual ~wxSocketManager() { }
+
+private:
+    // get the manager to use if we don't have it yet
+    static void Init();
+
+    static wxSocketManager *ms_manager;
+};
+
+/*
+    Base class for all socket implementations providing functionality common to
+    BSD and Winsock sockets.
+
+    Objects of this class are not created directly but only via its static
+    Create() method which in turn forwards to wxSocketManager::CreateSocket().
+ */
+class wxSocketImpl
+{
+public:
+    // static factory function: creates the low-level socket associated with
+    // the given wxSocket (and inherits its attributes such as timeout)
+    static wxSocketImpl *Create(wxSocketBase& wxsocket);
+
+    virtual ~wxSocketImpl();
+
+    // set various socket properties: all of those can only be called before
+    // creating the socket
+    void SetTimeout(unsigned long millisec);
+    void SetNonBlocking(bool non_blocking) { m_non_blocking = non_blocking; }
+    void SetReusable() { m_reusable = true; }
+    void SetBroadcast() { m_broadcast = true; }
+    void DontDoBind() { m_dobind = false; }
+    void SetInitialSocketBuffers(int recv, int send)
+    {
+        m_initialRecvBufferSize = recv;
+        m_initialSendBufferSize = send;
+    }
+
+    wxSocketError SetLocal(GAddress *address);
+    wxSocketError SetPeer(GAddress *address);
+
+    // accessors
+    // ---------
+
+    GAddress *GetLocal();
+    GAddress *GetPeer();
+
+    wxSocketError GetError() const { return m_error; }
+    bool IsOk() const { return m_error == wxSOCKET_NOERROR; }
+
+
+    // creating/closing the socket
+    // --------------------------
+
+    // notice that SetLocal() must be called before creating the socket using
+    // any of the functions below
+    //
+    // all of Create() functions return wxSOCKET_NOERROR if the operation
+    // completed successfully or one of:
+    //  wxSOCKET_INVSOCK - the socket is in use.
+    //  wxSOCKET_INVADDR - the local (server) or peer (client) address has not
+    //                     been set.
+    //  wxSOCKET_IOERR   - any other error.
+
+    // create a socket listening on the local address specified by SetLocal()
+    // (notice that DontDoBind() is ignored by this function)
+    wxSocketError CreateServer();
+
+    // create a socket connected to the peer address specified by SetPeer()
+    // (notice that DontDoBind() is ignored by this function)
+    //
+    // this function may return wxSOCKET_WOULDBLOCK in addition to the return
+    // values listed above
+    wxSocketError CreateClient();
+
+    // create (and bind unless DontDoBind() had been called) an UDP socket
+    // associated with the given local address
+    wxSocketError CreateUDP();
+
+    // may be called whether the socket was created or not, calls DoClose() if
+    // it was indeed created
+    void Close();
+
+    virtual void Shutdown();
+
+
+    // IO operations
+    // -------------
+
+    virtual int Read(char *buffer, int size) = 0;
+    virtual int Write(const char *buffer, int size) = 0;
+
+    wxSocketEventFlags Select(wxSocketEventFlags flags);
+
+    virtual wxSocketImpl *WaitConnection(wxSocketBase& wxsocket) = 0;
+
+
+    // notifications
+    // -------------
+
+    // notify m_wxsocket about the given socket event by calling its (inaptly
+    // named) OnRequest() method
+    void NotifyOnStateChange(wxSocketNotify event);
+
+    // FIXME: making these functions virtual is a hack necessary to make the
+    //        wxBase library link without requiring wxNet under Unix where
+    //        wxSocketSelectManager (part of wxBase) uses them, they don't
+    //        really need to be virtual at all
+    virtual void Detected_Read() { }
+    virtual void Detected_Write() { }
+    virtual void Notify(bool WXUNUSED(notify)) { }
+
+    // TODO: make these fields protected and provide accessors for those of
+    //       them that wxSocketBase really needs
+//protected:
+    SOCKET m_fd;
+
+    int m_initialRecvBufferSize;
+    int m_initialSendBufferSize;
+
+    GAddress *m_local;
+    GAddress *m_peer;
+    wxSocketError m_error;
+
+    bool m_non_blocking;
+    bool m_server;
+    bool m_stream;
+    bool m_establishing;
+    bool m_reusable;
+    bool m_broadcast;
+    bool m_dobind;
+
+    struct timeval m_timeout;
+
+    wxSocketEventFlags m_detected;
+
+protected:
+    wxSocketImpl(wxSocketBase& wxsocket);
+
+private:
+    // handle the given connect() return value (which may be 0 or EWOULDBLOCK
+    // or something else)
+    virtual wxSocketError DoHandleConnect(int ret) = 0;
+
+    // called by Close() if we have a valid m_fd
+    virtual void DoClose() = 0;
+
+    // put this socket into non-blocking mode and enable monitoring this socket
+    // as part of the event loop
+    virtual void UnblockAndRegisterWithEventLoop() = 0;
+
+    // check that the socket wasn't created yet and that the given address
+    // (either m_local or m_peer depending on the socket kind) is valid and
+    // set m_error and return false if this is not the case
+    bool PreCreateCheck(GAddress *addr);
+
+    // set the given socket option: this just wraps setsockopt(SOL_SOCKET)
+    int SetSocketOption(int optname, int optval)
+    {
+        // although modern Unix systems use "const void *" for the 4th
+        // parameter here, old systems and Winsock still use "const char *"
+        return setsockopt(m_fd, SOL_SOCKET, optname,
+                          reinterpret_cast<const char *>(&optval),
+                          sizeof(optval));
+    }
+
+    // set the given socket option to true value: this is an even simpler
+    // wrapper for setsockopt(SOL_SOCKET) for boolean options
+    int EnableSocketOption(int optname)
+    {
+        return SetSocketOption(optname, 1);
+    }
+
+    // apply the options to the (just created) socket and register it with the
+    // event loop by calling UnblockAndRegisterWithEventLoop()
+    void PostCreation();
+
+    // update local address after binding/connecting
+    wxSocketError UpdateLocalAddress();
+
+
+    // set in ctor and never changed except that it's reset to NULL when the
+    // socket is shut down
+    wxSocketBase *m_wxsocket;
+
+    DECLARE_NO_COPY_CLASS(wxSocketImpl)
+};
+
+#if defined(__WXMSW__)
+    #include "wx/msw/gsockmsw.h"
+#else
+    #include "wx/unix/private/sockunix.h"
+#endif
+
+
+/* GAddress */
+
+// TODO: make GAddress a real class instead of this mix of C and C++
+
+// Represents a socket endpoint, i.e. -- in spite of its name -- not an address
+// but an (address, port) pair
+struct GAddress
+{
+    struct sockaddr *m_addr;
+    size_t m_len;
+
+    GAddressType m_family;
+    int m_realfamily;
+
+    wxSocketError m_error;
+};
+
+GAddress *GAddress_new();
+GAddress *GAddress_copy(GAddress *address);
+void GAddress_destroy(GAddress *address);
+
+void GAddress_SetFamily(GAddress *address, GAddressType type);
+GAddressType GAddress_GetFamily(GAddress *address);
+
+/* The use of any of the next functions will set the address family to
+ * the specific one. For example if you use GAddress_INET_SetHostName,
+ * address family will be implicitly set to AF_INET.
+ */
+
+wxSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname);
+wxSocketError GAddress_INET_SetBroadcastAddress(GAddress *address);
+wxSocketError GAddress_INET_SetAnyAddress(GAddress *address);
+wxSocketError GAddress_INET_SetHostAddress(GAddress *address,
+                                          unsigned long hostaddr);
+wxSocketError GAddress_INET_SetPortName(GAddress *address, const char *port,
+                                       const char *protocol);
+wxSocketError GAddress_INET_SetPort(GAddress *address, unsigned short port);
+
+wxSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname,
+                                       size_t sbuf);
+unsigned long GAddress_INET_GetHostAddress(GAddress *address);
+unsigned short GAddress_INET_GetPort(GAddress *address);
+
+wxSocketError _GAddress_translate_from(GAddress *address,
+                                      struct sockaddr *addr, int len);
+wxSocketError _GAddress_translate_to  (GAddress *address,
+                                      struct sockaddr **addr, int *len);
+wxSocketError _GAddress_Init_INET(GAddress *address);
+
+#if wxUSE_IPV6
+
+wxSocketError GAddress_INET6_SetHostName(GAddress *address, const char *hostname);
+wxSocketError GAddress_INET6_SetAnyAddress(GAddress *address);
+wxSocketError GAddress_INET6_SetHostAddress(GAddress *address,
+                                          struct in6_addr hostaddr);
+wxSocketError GAddress_INET6_SetPortName(GAddress *address, const char *port,
+                                       const char *protocol);
+wxSocketError GAddress_INET6_SetPort(GAddress *address, unsigned short port);
+
+wxSocketError GAddress_INET6_GetHostName(GAddress *address, char *hostname,
+                                       size_t sbuf);
+wxSocketError GAddress_INET6_GetHostAddress(GAddress *address,struct in6_addr *hostaddr);
+unsigned short GAddress_INET6_GetPort(GAddress *address);
+
+#endif // wxUSE_IPV6
+
+// these functions are available under all platforms but only implemented under
+// Unix ones, elsewhere they just return wxSOCKET_INVADDR
+wxSocketError _GAddress_Init_UNIX(GAddress *address);
+wxSocketError GAddress_UNIX_SetPath(GAddress *address, const char *path);
+wxSocketError GAddress_UNIX_GetPath(GAddress *address, char *path, size_t sbuf);
+
+#endif /* wxUSE_SOCKETS */
 
 
+#endif /* _WX_PRIVATE_SOCKET_H_ */
diff --git a/include/wx/unix/gsockunx.h b/include/wx/unix/gsockunx.h
deleted file mode 100644 (file)
index 21ffe39..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name:        wx/unix/gsockunx.h
-// Purpose:     wxSocketImpl implementation for Unix systems
-// Authors:     Guilhem Lavaux, Vadim Zeitlin
-// Created:     April 1997
-// RCS-ID:      $Id$
-// Copyright:   (c) 1997 Guilhem Lavaux
-//              (c) 2008 Vadim Zeitlin
-// Licence:     wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_UNIX_GSOCKUNX_H_
-#define _WX_UNIX_GSOCKUNX_H_
-
-#include <unistd.h>
-#include <sys/ioctl.h>
-
-class wxSocketIOHandler;
-
-class wxSocketImplUnix : public wxSocketImpl
-{
-public:
-    wxSocketImplUnix(wxSocketBase& wxsocket);
-
-    virtual void Shutdown();
-    virtual wxSocketImpl *WaitConnection(wxSocketBase& wxsocket);
-
-    int Read(char *buffer, int size);
-    int Write(const char *buffer, int size);
-    //attach or detach from main loop
-    void Notify(bool flag);
-    void Detected_Read();
-    void Detected_Write();
-
-private:
-    virtual wxSocketError DoHandleConnect(int ret);
-    virtual void DoClose()
-    {
-        wxSocketManager * const manager = wxSocketManager::Get();
-        if ( manager )
-        {
-            manager->Uninstall_Callback(this, wxSOCKET_INPUT);
-            manager->Uninstall_Callback(this, wxSOCKET_OUTPUT);
-        }
-
-        close(m_fd);
-    }
-
-    virtual void UnblockAndRegisterWithEventLoop()
-    {
-        int trueArg = 1;
-        ioctl(m_fd, FIONBIO, &trueArg);
-
-        EnableEvents();
-    }
-
-    // enable or disable notifications for socket input/output events but only
-    // if m_use_events is true; do nothing otherwise
-    virtual void EnableEvents()
-    {
-        if ( m_use_events )
-            DoEnableEvents(true);
-    }
-
-    void DisableEvents()
-    {
-        if ( m_use_events )
-            DoEnableEvents(false);
-    }
-
-    // really enable or disable socket input/output events, regardless of
-    // m_use_events value
-    void DoEnableEvents(bool enable);
-
-
-    // enable or disable events for the given event if m_use_events; do nothing
-    // otherwise
-    //
-    // notice that these functions also update m_detected: EnableEvent() clears
-    // the corresponding bit in it and DisableEvent() sets it
-    void EnableEvent(wxSocketNotify event);
-    void DisableEvent(wxSocketNotify event);
-
-
-    wxSocketError Input_Timeout();
-    wxSocketError Output_Timeout();
-    int Recv_Stream(char *buffer, int size);
-    int Recv_Dgram(char *buffer, int size);
-    int Send_Stream(const char *buffer, int size);
-    int Send_Dgram(const char *buffer, int size);
-
-protected:
-    // true if socket should fire events
-    bool m_use_events;
-
-    // descriptors for input and output event notification channels associated
-    // with the socket
-    int m_fds[2];
-
-private:
-    // notify the associated wxSocket about a change in socket state and shut
-    // down the socket if the event is wxSOCKET_LOST
-    void OnStateChange(wxSocketNotify event);
-
-    // give it access to our m_fds
-    friend class wxSocketFDBasedManager;
-};
-
-// A version of wxSocketManager which uses FDs for socket IO
-class wxSocketFDBasedManager : public wxSocketManager
-{
-public:
-    // no special initialization/cleanup needed when using FDs
-    virtual bool OnInit() { return true; }
-    virtual void OnExit() { }
-
-    // allocate/free the storage we need
-    virtual wxSocketImpl *CreateSocket(wxSocketBase& wxsocket)
-    {
-        return new wxSocketImplUnix(wxsocket);
-    }
-
-protected:
-    // identifies either input or output direction
-    //
-    // NB: the values of this enum shouldn't change
-    enum SocketDir
-    {
-        FD_INPUT,
-        FD_OUTPUT
-    };
-
-    // get the FD index corresponding to the given wxSocketNotify
-    SocketDir GetDirForEvent(wxSocketImpl *socket, wxSocketNotify event)
-    {
-        switch ( event )
-        {
-            default:
-                wxFAIL_MSG( "unexpected socket event" );
-                // fall through
-
-            case wxSOCKET_LOST:
-                // fall through
-
-            case wxSOCKET_INPUT:
-                return FD_INPUT;
-
-            case wxSOCKET_OUTPUT:
-                return FD_OUTPUT;
-
-            case wxSOCKET_CONNECTION:
-                // FIXME: explain this?
-                return socket->m_server ? FD_INPUT : FD_OUTPUT;
-        }
-    }
-
-    // access the FDs we store
-    int& FD(wxSocketImpl *socket, SocketDir d)
-    {
-        return static_cast<wxSocketImplUnix *>(socket)->m_fds[d];
-    }
-};
-
-// Common base class for all ports using X11-like (and hence implemented in
-// X11, Motif and GTK) AddInput() and RemoveInput() functions
-class wxSocketInputBasedManager : public wxSocketFDBasedManager
-{
-public:
-    virtual void Install_Callback(wxSocketImpl *socket, wxSocketNotify event)
-    {
-        wxCHECK_RET( socket->m_fd != -1,
-                        "shouldn't be called on invalid socket" );
-
-        const SocketDir d = GetDirForEvent(socket, event);
-
-        int& fd = FD(socket, d);
-        if ( fd != -1 )
-            RemoveInput(fd);
-
-        fd = AddInput(socket, d);
-    }
-
-    virtual void Uninstall_Callback(wxSocketImpl *socket, wxSocketNotify event)
-    {
-        const SocketDir d = GetDirForEvent(socket, event);
-
-        int& fd = FD(socket, d);
-        if ( fd != -1 )
-        {
-            RemoveInput(fd);
-            fd = -1;
-        }
-    }
-
-private:
-    // these functions map directly to XtAdd/RemoveInput() or
-    // gdk_input_add/remove()
-    virtual int AddInput(wxSocketImpl *socket, SocketDir d) = 0;
-    virtual void RemoveInput(int fd) = 0;
-};
-
-#endif  /* _WX_UNIX_GSOCKUNX_H_ */
diff --git a/include/wx/unix/private/sockunix.h b/include/wx/unix/private/sockunix.h
new file mode 100644 (file)
index 0000000..3dc2f9d
--- /dev/null
@@ -0,0 +1,202 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        wx/unix/private/sockunix.h
+// Purpose:     wxSocketImpl implementation for Unix systems
+// Authors:     Guilhem Lavaux, Vadim Zeitlin
+// Created:     April 1997
+// RCS-ID:      $Id$
+// Copyright:   (c) 1997 Guilhem Lavaux
+//              (c) 2008 Vadim Zeitlin
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_UNIX_GSOCKUNX_H_
+#define _WX_UNIX_GSOCKUNX_H_
+
+#include <unistd.h>
+#include <sys/ioctl.h>
+
+class wxSocketIOHandler;
+
+class wxSocketImplUnix : public wxSocketImpl
+{
+public:
+    wxSocketImplUnix(wxSocketBase& wxsocket);
+
+    virtual void Shutdown();
+    virtual wxSocketImpl *WaitConnection(wxSocketBase& wxsocket);
+
+    int Read(char *buffer, int size);
+    int Write(const char *buffer, int size);
+    //attach or detach from main loop
+    void Notify(bool flag);
+    void Detected_Read();
+    void Detected_Write();
+
+private:
+    virtual wxSocketError DoHandleConnect(int ret);
+    virtual void DoClose()
+    {
+        wxSocketManager * const manager = wxSocketManager::Get();
+        if ( manager )
+        {
+            manager->Uninstall_Callback(this, wxSOCKET_INPUT);
+            manager->Uninstall_Callback(this, wxSOCKET_OUTPUT);
+        }
+
+        close(m_fd);
+    }
+
+    virtual void UnblockAndRegisterWithEventLoop()
+    {
+        int trueArg = 1;
+        ioctl(m_fd, FIONBIO, &trueArg);
+
+        EnableEvents();
+    }
+
+    // enable or disable notifications for socket input/output events but only
+    // if m_use_events is true; do nothing otherwise
+    virtual void EnableEvents()
+    {
+        if ( m_use_events )
+            DoEnableEvents(true);
+    }
+
+    void DisableEvents()
+    {
+        if ( m_use_events )
+            DoEnableEvents(false);
+    }
+
+    // really enable or disable socket input/output events, regardless of
+    // m_use_events value
+    void DoEnableEvents(bool enable);
+
+
+    // enable or disable events for the given event if m_use_events; do nothing
+    // otherwise
+    //
+    // notice that these functions also update m_detected: EnableEvent() clears
+    // the corresponding bit in it and DisableEvent() sets it
+    void EnableEvent(wxSocketNotify event);
+    void DisableEvent(wxSocketNotify event);
+
+
+    wxSocketError Input_Timeout();
+    wxSocketError Output_Timeout();
+    int Recv_Stream(char *buffer, int size);
+    int Recv_Dgram(char *buffer, int size);
+    int Send_Stream(const char *buffer, int size);
+    int Send_Dgram(const char *buffer, int size);
+
+protected:
+    // true if socket should fire events
+    bool m_use_events;
+
+    // descriptors for input and output event notification channels associated
+    // with the socket
+    int m_fds[2];
+
+private:
+    // notify the associated wxSocket about a change in socket state and shut
+    // down the socket if the event is wxSOCKET_LOST
+    void OnStateChange(wxSocketNotify event);
+
+    // give it access to our m_fds
+    friend class wxSocketFDBasedManager;
+};
+
+// A version of wxSocketManager which uses FDs for socket IO
+class wxSocketFDBasedManager : public wxSocketManager
+{
+public:
+    // no special initialization/cleanup needed when using FDs
+    virtual bool OnInit() { return true; }
+    virtual void OnExit() { }
+
+    // allocate/free the storage we need
+    virtual wxSocketImpl *CreateSocket(wxSocketBase& wxsocket)
+    {
+        return new wxSocketImplUnix(wxsocket);
+    }
+
+protected:
+    // identifies either input or output direction
+    //
+    // NB: the values of this enum shouldn't change
+    enum SocketDir
+    {
+        FD_INPUT,
+        FD_OUTPUT
+    };
+
+    // get the FD index corresponding to the given wxSocketNotify
+    SocketDir GetDirForEvent(wxSocketImpl *socket, wxSocketNotify event)
+    {
+        switch ( event )
+        {
+            default:
+                wxFAIL_MSG( "unexpected socket event" );
+                // fall through
+
+            case wxSOCKET_LOST:
+                // fall through
+
+            case wxSOCKET_INPUT:
+                return FD_INPUT;
+
+            case wxSOCKET_OUTPUT:
+                return FD_OUTPUT;
+
+            case wxSOCKET_CONNECTION:
+                // FIXME: explain this?
+                return socket->m_server ? FD_INPUT : FD_OUTPUT;
+        }
+    }
+
+    // access the FDs we store
+    int& FD(wxSocketImpl *socket, SocketDir d)
+    {
+        return static_cast<wxSocketImplUnix *>(socket)->m_fds[d];
+    }
+};
+
+// Common base class for all ports using X11-like (and hence implemented in
+// X11, Motif and GTK) AddInput() and RemoveInput() functions
+class wxSocketInputBasedManager : public wxSocketFDBasedManager
+{
+public:
+    virtual void Install_Callback(wxSocketImpl *socket, wxSocketNotify event)
+    {
+        wxCHECK_RET( socket->m_fd != -1,
+                        "shouldn't be called on invalid socket" );
+
+        const SocketDir d = GetDirForEvent(socket, event);
+
+        int& fd = FD(socket, d);
+        if ( fd != -1 )
+            RemoveInput(fd);
+
+        fd = AddInput(socket, d);
+    }
+
+    virtual void Uninstall_Callback(wxSocketImpl *socket, wxSocketNotify event)
+    {
+        const SocketDir d = GetDirForEvent(socket, event);
+
+        int& fd = FD(socket, d);
+        if ( fd != -1 )
+        {
+            RemoveInput(fd);
+            fd = -1;
+        }
+    }
+
+private:
+    // these functions map directly to XtAdd/RemoveInput() or
+    // gdk_input_add/remove()
+    virtual int AddInput(wxSocketImpl *socket, SocketDir d) = 0;
+    virtual void RemoveInput(int fd) = 0;
+};
+
+#endif  /* _WX_UNIX_GSOCKUNX_H_ */
index aee1b58cbf07e574a257a93341009c9594451941..ceccf92083571d2d9183c3b4ff3e4039628a3bbf 100644 (file)
@@ -32,9 +32,9 @@
     #endif
 #endif // !WX_PRECOMP
 
     #endif
 #endif // !WX_PRECOMP
 
-#include "wx/private/gsocket.h"
 #include "wx/socket.h"
 #include "wx/sckaddr.h"
 #include "wx/socket.h"
 #include "wx/sckaddr.h"
+#include "wx/private/socket.h"
 
 IMPLEMENT_ABSTRACT_CLASS(wxSockAddress, wxObject)
 IMPLEMENT_ABSTRACT_CLASS(wxIPaddress, wxSockAddress)
 
 IMPLEMENT_ABSTRACT_CLASS(wxSockAddress, wxObject)
 IMPLEMENT_ABSTRACT_CLASS(wxIPaddress, wxSockAddress)
index a4fb0d8f73f1468abc16d40a1f5d5e4449da8322..541749394e6312b058fecf892314f01118f3d5eb 100644 (file)
@@ -44,7 +44,7 @@
 #include "wx/evtloop.h"
 
 #include "wx/private/fd.h"
 #include "wx/evtloop.h"
 
 #include "wx/private/fd.h"
-#include "wx/private/gsocket.h"
+#include "wx/private/socket.h"
 
 // DLL options compatibility check:
 #include "wx/build.h"
 
 // DLL options compatibility check:
 #include "wx/build.h"
diff --git a/src/gtk/gsockgtk.cpp b/src/gtk/gsockgtk.cpp
deleted file mode 100644 (file)
index c847b5a..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Name:        gtk/gsockgtk.cpp
-// Purpose:     implementation of wxGTK-specific socket event handling
-// Author:      Guilhem Lavaux, Vadim Zeitlin
-// Created:     1999
-// RCS-ID:      $Id$
-// Copyright:   (c) 1999, 2007 wxWidgets dev team
-// Licence:     wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#if wxUSE_SOCKETS
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <gdk/gdk.h>
-#include <glib.h>
-
-#include "wx/private/gsocket.h"
-#include "wx/apptrait.h"
-
-extern "C" {
-static
-void wxSocket_GDK_Input(gpointer data,
-                        gint WXUNUSED(source),
-                        GdkInputCondition condition)
-{
-    wxSocketImpl * const socket = static_cast<wxSocketImpl *>(data);
-
-    if ( condition & GDK_INPUT_READ )
-        socket->Detected_Read();
-    if ( condition & GDK_INPUT_WRITE )
-        socket->Detected_Write();
-}
-}
-
-class GTKSocketManager : public wxSocketInputBasedManager
-{
-public:
-    virtual int AddInput(wxSocketImpl *socket, SocketDir d)
-    {
-        return gdk_input_add
-               (
-                    socket->m_fd,
-                    d == FD_OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ,
-                    wxSocket_GDK_Input,
-                    socket
-               );
-    }
-
-    virtual void RemoveInput(int fd)
-    {
-        gdk_input_remove(fd);
-    }
-};
-
-wxSocketManager *wxGUIAppTraits::GetSocketManager()
-{
-    static GTKSocketManager s_manager;
-    return &s_manager;
-}
-
-#endif // wxUSE_SOCKETS
diff --git a/src/gtk/sockgtk.cpp b/src/gtk/sockgtk.cpp
new file mode 100644 (file)
index 0000000..bd80f85
--- /dev/null
@@ -0,0 +1,66 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        gtk/gsockgtk.cpp
+// Purpose:     implementation of wxGTK-specific socket event handling
+// Author:      Guilhem Lavaux, Vadim Zeitlin
+// Created:     1999
+// RCS-ID:      $Id$
+// Copyright:   (c) 1999, 2007 wxWidgets dev team
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#if wxUSE_SOCKETS
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <gdk/gdk.h>
+#include <glib.h>
+
+#include "wx/private/socket.h"
+#include "wx/apptrait.h"
+
+extern "C" {
+static
+void wxSocket_GDK_Input(gpointer data,
+                        gint WXUNUSED(source),
+                        GdkInputCondition condition)
+{
+    wxSocketImpl * const socket = static_cast<wxSocketImpl *>(data);
+
+    if ( condition & GDK_INPUT_READ )
+        socket->Detected_Read();
+    if ( condition & GDK_INPUT_WRITE )
+        socket->Detected_Write();
+}
+}
+
+class GTKSocketManager : public wxSocketInputBasedManager
+{
+public:
+    virtual int AddInput(wxSocketImpl *socket, SocketDir d)
+    {
+        return gdk_input_add
+               (
+                    socket->m_fd,
+                    d == FD_OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ,
+                    wxSocket_GDK_Input,
+                    socket
+               );
+    }
+
+    virtual void RemoveInput(int fd)
+    {
+        gdk_input_remove(fd);
+    }
+};
+
+wxSocketManager *wxGUIAppTraits::GetSocketManager()
+{
+    static GTKSocketManager s_manager;
+    return &s_manager;
+}
+
+#endif // wxUSE_SOCKETS
diff --git a/src/gtk1/gsockgtk.cpp b/src/gtk1/gsockgtk.cpp
deleted file mode 100644 (file)
index 8a6eab7..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Name:        gtk/gsockgtk.cpp
-// Purpose:     implementation of wxGTK-specific socket event handling
-// Author:      Guilhem Lavaux, Vadim Zeitlin
-// Created:     1999
-// RCS-ID:      $Id$
-// Copyright:   (c) 1999, 2007 wxWidgets dev team
-// Licence:     wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#if wxUSE_SOCKETS
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <gdk/gdk.h>
-#include <glib.h>
-
-#include "wx/private/gsocket.h"
-#include "wx/apptrait.h"
-
-extern "C" {
-static
-void wxSocket_GDK_Input(gpointer data,
-                        gint WXUNUSED(source),
-                        GdkInputCondition condition)
-{
-  wxSocketImpl const *socket = static_cast<wxSocketImpl *>(data);
-
-  if ( condition & GDK_INPUT_READ )
-    socket->Detected_Read();
-  if ( condition & GDK_INPUT_WRITE )
-    socket->Detected_Write();
-}
-}
-
-class GTKSocketManager : public wxSocketInputBasedManager
-{
-public:
-    virtual int AddInput(wxSocketImpl *socket, SocketDir d)
-    {
-        return gdk_input_add
-               (
-                    socket->m_fd,
-                    d == FD_OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ,
-                    wxSocket_GDK_Input,
-                    socket
-               );
-    }
-
-    virtual void RemoveInput(int fd)
-    {
-        gdk_input_remove(fd);
-    }
-};
-
-wxSocketManager *wxGUIAppTraits::GetSocketManager()
-{
-    static GTKSocketManager s_manager;
-    return &s_manager;
-}
-
-#endif // wxUSE_SOCKETS
diff --git a/src/gtk1/sockgtk.cpp b/src/gtk1/sockgtk.cpp
new file mode 100644 (file)
index 0000000..b8b1ecb
--- /dev/null
@@ -0,0 +1,66 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        gtk/gsockgtk.cpp
+// Purpose:     implementation of wxGTK-specific socket event handling
+// Author:      Guilhem Lavaux, Vadim Zeitlin
+// Created:     1999
+// RCS-ID:      $Id$
+// Copyright:   (c) 1999, 2007 wxWidgets dev team
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#if wxUSE_SOCKETS
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <gdk/gdk.h>
+#include <glib.h>
+
+#include "wx/private/socket.h"
+#include "wx/apptrait.h"
+
+extern "C" {
+static
+void wxSocket_GDK_Input(gpointer data,
+                        gint WXUNUSED(source),
+                        GdkInputCondition condition)
+{
+  wxSocketImpl const *socket = static_cast<wxSocketImpl *>(data);
+
+  if ( condition & GDK_INPUT_READ )
+    socket->Detected_Read();
+  if ( condition & GDK_INPUT_WRITE )
+    socket->Detected_Write();
+}
+}
+
+class GTKSocketManager : public wxSocketInputBasedManager
+{
+public:
+    virtual int AddInput(wxSocketImpl *socket, SocketDir d)
+    {
+        return gdk_input_add
+               (
+                    socket->m_fd,
+                    d == FD_OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ,
+                    wxSocket_GDK_Input,
+                    socket
+               );
+    }
+
+    virtual void RemoveInput(int fd)
+    {
+        gdk_input_remove(fd);
+    }
+};
+
+wxSocketManager *wxGUIAppTraits::GetSocketManager()
+{
+    static GTKSocketManager s_manager;
+    return &s_manager;
+}
+
+#endif // wxUSE_SOCKETS
diff --git a/src/motif/gsockmot.cpp b/src/motif/gsockmot.cpp
deleted file mode 100644 (file)
index 468489d..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Name:        motif/gsockmot.cpp
-// Purpose:     implementation of wxMotif-specific socket event handling
-// Author:      Guilhem Lavaux, Vadim Zeitlin
-// Created:     1999
-// RCS-ID:      $Id$
-// Copyright:   (c) 1999, 2007 wxWidgets dev team
-// Licence:     wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#if wxUSE_SOCKETS
-
-#include <X11/Intrinsic.h>      // XtAppAdd/RemoveInput()
-#include "wx/motif/private.h"   // wxGetAppContext()
-#include "wx/private/gsocket.h"
-#include "wx/apptrait.h"
-
-extern "C" {
-
-static void wxSocket_Motif_Input(XtPointer data, int *WXUNUSED(fid),
-                                 XtInputId *WXUNUSED(id))
-{
-    wxSocketImpl * const socket = static_cast<wxSocketImpl *>(data);
-
-    socket->Detected_Read();
-}
-
-static void wxSocket_Motif_Output(XtPointer data, int *WXUNUSED(fid),
-                                  XtInputId *WXUNUSED(id))
-{
-    wxSocketImpl * const socket = static_cast<wxSocketImpl *>(data);
-
-    socket->Detected_Write();
-}
-
-}
-
-class MotifSocketManager : public wxSocketInputBasedManager
-{
-public:
-    virtual int AddInput(wxSocketImpl *socket, SocketDir d)
-    {
-        return XtAppAddInput
-               (
-                    wxGetAppContext(),
-                    socket->m_fd,
-                    (XtPointer)(d == FD_OUTPUT ? XtInputWriteMask
-                                               : XtInputReadMask),
-                    d == FD_OUTPUT ? wxSocket_Motif_Output
-                                   : wxSocket_Motif_Input,
-                    socket
-               );
-    }
-
-    virtual void RemoveInput(int fd)
-    {
-        XtRemoveInput(fd);
-    }
-};
-
-wxSocketManager *wxGUIAppTraits::GetSocketManager()
-{
-    static MotifSocketManager s_manager;
-    return &s_manager;
-}
-
-#endif // wxUSE_SOCKETS
diff --git a/src/motif/sockmot.cpp b/src/motif/sockmot.cpp
new file mode 100644 (file)
index 0000000..98257dd
--- /dev/null
@@ -0,0 +1,70 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        motif/gsockmot.cpp
+// Purpose:     implementation of wxMotif-specific socket event handling
+// Author:      Guilhem Lavaux, Vadim Zeitlin
+// Created:     1999
+// RCS-ID:      $Id$
+// Copyright:   (c) 1999, 2007 wxWidgets dev team
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#if wxUSE_SOCKETS
+
+#include <X11/Intrinsic.h>      // XtAppAdd/RemoveInput()
+#include "wx/motif/private.h"   // wxGetAppContext()
+#include "wx/private/socket.h"
+#include "wx/apptrait.h"
+
+extern "C" {
+
+static void wxSocket_Motif_Input(XtPointer data, int *WXUNUSED(fid),
+                                 XtInputId *WXUNUSED(id))
+{
+    wxSocketImpl * const socket = static_cast<wxSocketImpl *>(data);
+
+    socket->Detected_Read();
+}
+
+static void wxSocket_Motif_Output(XtPointer data, int *WXUNUSED(fid),
+                                  XtInputId *WXUNUSED(id))
+{
+    wxSocketImpl * const socket = static_cast<wxSocketImpl *>(data);
+
+    socket->Detected_Write();
+}
+
+}
+
+class MotifSocketManager : public wxSocketInputBasedManager
+{
+public:
+    virtual int AddInput(wxSocketImpl *socket, SocketDir d)
+    {
+        return XtAppAddInput
+               (
+                    wxGetAppContext(),
+                    socket->m_fd,
+                    (XtPointer)(d == FD_OUTPUT ? XtInputWriteMask
+                                               : XtInputReadMask),
+                    d == FD_OUTPUT ? wxSocket_Motif_Output
+                                   : wxSocket_Motif_Input,
+                    socket
+               );
+    }
+
+    virtual void RemoveInput(int fd)
+    {
+        XtRemoveInput(fd);
+    }
+};
+
+wxSocketManager *wxGUIAppTraits::GetSocketManager()
+{
+    static MotifSocketManager s_manager;
+    return &s_manager;
+}
+
+#endif // wxUSE_SOCKETS
index f611abaea5531b9dc11fd7919dba709c47001c83..0e8bbd39dfed50f8928231ef4bf20ba1a0a9f2ed 100644 (file)
@@ -57,7 +57,7 @@
 
 #if wxUSE_SOCKETS
 
 
 #if wxUSE_SOCKETS
 
-#include "wx/private/gsocket.h"
+#include "wx/private/socket.h"
 #include "wx/link.h"
 
 wxFORCE_LINK_MODULE(gsockmsw)
 #include "wx/link.h"
 
 wxFORCE_LINK_MODULE(gsockmsw)
index 69ced421190c05f9dc9e196e6061bf325c0b8e3f..4215428a26cf28c5a5777cbcf04a0f4b5a1efbeb 100644 (file)
@@ -38,7 +38,7 @@
 #   pragma warning(disable:4115) /* named type definition in parentheses */
 #endif
 
 #   pragma warning(disable:4115) /* named type definition in parentheses */
 #endif
 
-#include "wx/private/gsocket.h"
+#include "wx/private/socket.h"
 #include "wx/apptrait.h"
 #include "wx/link.h"
 
 #include "wx/apptrait.h"
 #include "wx/link.h"
 
diff --git a/src/os2/gsockpm.cpp b/src/os2/gsockpm.cpp
deleted file mode 100644 (file)
index ec7d114..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -------------------------------------------------------------------------
- * Project: wxSocketImpl (Generic Socket) for WX
- * Name:    gsockpm.c
- * Purpose: wxSocketImpl: PM part
- * Licence: The wxWindows licence
- * CVSID:   $Id$
- * ------------------------------------------------------------------------- */
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#if wxUSE_SOCKETS
-
-#include <stdlib.h>
-#include "wx/private/gsocket.h"
-#include "wx/app.h"
-#include "wx/apptrait.h"
-
-#define wxSockReadMask  0x01
-#define wxSockWriteMask 0x02
-
-static void wxSocket_PM_Input(void *data)
-{
-    wxSocketImpl *socket = static_cast<wxSocketImpl *>(data);
-
-    socket->Detected_Read();
-}
-
-static void wxSocket_PM_Output(void *data)
-{
-    wxSocketImpl *socket = static_cast<wxSocketImpl *>(data);
-
-    socket->Detected_Write();
-}
-
-class PMSocketManager : public wxSocketInputBasedManager
-{
-public:
-    virtual int AddInput(wxSocketImpl *socket, SocketDir d)
-    {
-
-      if (d == FD_OUTPUT)
-          return wxTheApp->AddSocketHandler(socket->m_fd, wxSockWriteMask,
-                                            wxSocket_PM_Output, (void *)socket);
-      else
-          return wxTheApp->AddSocketHandler(socket->m_fd, wxSockReadMask,
-                                            wxSocket_PM_Input, (void *)socket);
-    }
-
-    virtual void RemoveInput(int fd)
-    {
-        wxTheApp->RemoveSocketHandler(fd);
-    }
-};
-
-wxSocketManager *wxGUIAppTraits::GetSocketManager()
-{
-    static PMSocketManager s_manager;
-    return &s_manager;
-}
-
-
-#else /* !wxUSE_SOCKETS */
-
-/* some compilers don't like having empty source files */
-static int wxDummyGsockVar = 0;
-
-#endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */
diff --git a/src/os2/sockpm.cpp b/src/os2/sockpm.cpp
new file mode 100644 (file)
index 0000000..8168d7f
--- /dev/null
@@ -0,0 +1,68 @@
+/* -------------------------------------------------------------------------
+ * Project: wxSocketImpl (Generic Socket) for WX
+ * Name:    gsockpm.c
+ * Purpose: wxSocketImpl: PM part
+ * Licence: The wxWindows licence
+ * CVSID:   $Id$
+ * ------------------------------------------------------------------------- */
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#if wxUSE_SOCKETS
+
+#include <stdlib.h>
+#include "wx/private/socket.h"
+#include "wx/app.h"
+#include "wx/apptrait.h"
+
+#define wxSockReadMask  0x01
+#define wxSockWriteMask 0x02
+
+static void wxSocket_PM_Input(void *data)
+{
+    wxSocketImpl *socket = static_cast<wxSocketImpl *>(data);
+
+    socket->Detected_Read();
+}
+
+static void wxSocket_PM_Output(void *data)
+{
+    wxSocketImpl *socket = static_cast<wxSocketImpl *>(data);
+
+    socket->Detected_Write();
+}
+
+class PMSocketManager : public wxSocketInputBasedManager
+{
+public:
+    virtual int AddInput(wxSocketImpl *socket, SocketDir d)
+    {
+
+      if (d == FD_OUTPUT)
+          return wxTheApp->AddSocketHandler(socket->m_fd, wxSockWriteMask,
+                                            wxSocket_PM_Output, (void *)socket);
+      else
+          return wxTheApp->AddSocketHandler(socket->m_fd, wxSockReadMask,
+                                            wxSocket_PM_Input, (void *)socket);
+    }
+
+    virtual void RemoveInput(int fd)
+    {
+        wxTheApp->RemoveSocketHandler(fd);
+    }
+};
+
+wxSocketManager *wxGUIAppTraits::GetSocketManager()
+{
+    static PMSocketManager s_manager;
+    return &s_manager;
+}
+
+
+#else /* !wxUSE_SOCKETS */
+
+/* some compilers don't like having empty source files */
+static int wxDummyGsockVar = 0;
+
+#endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */
diff --git a/src/osx/core/gsockosx.cpp b/src/osx/core/gsockosx.cpp
deleted file mode 100644 (file)
index d443e4b..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name:        osx/core/gsockosx.cpp
-// Purpose:     wxSocketImpl implementation for OS X
-// Authors:     Brian Victor, Vadim Zeitlin
-// Created:     February 2002
-// RCS-ID:      $Id$
-// Copyright:   (c) 2002 Brian Victor
-//              (c) 2008 Vadim Zeitlin
-// Licence:     wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#if wxUSE_SOCKETS
-
-#include "wx/private/gsocket.h"
-#include "wx/unix/gsockunx.h"
-#include "wx/apptrait.h"
-
-#include <CoreFoundation/CoreFoundation.h>
-
-namespace
-{
-
-// ----------------------------------------------------------------------------
-// global variables
-// ----------------------------------------------------------------------------
-
-// Sockets must use the event loop to monitor the events so we store a
-// reference to the main thread event loop here
-static CFRunLoopRef gs_mainRunLoop = NULL;
-
-// ----------------------------------------------------------------------------
-// Mac-specific socket implementation
-// ----------------------------------------------------------------------------
-
-class wxSocketImplMac : public wxSocketImplUnix
-{
-public:
-    wxSocketImplMac(wxSocketBase& wxsocket)
-        : wxSocketImplUnix(wxsocket)
-    {
-        m_socket = NULL;
-        m_source = NULL;
-    }
-
-    virtual ~wxSocketImplMac()
-    {
-        wxASSERT_MSG( !m_source && !m_socket, "forgot to call Close()?" );
-    }
-
-    // get the underlying socket: creates it on demand
-    CFSocketRef GetSocket() /* const */
-    {
-        if ( !m_socket )
-            Initialize();
-
-        return m_socket;
-    }
-
-private:
-    virtual void DoClose()
-    {
-        wxSocketManager * const manager = wxSocketManager::Get();
-        if ( manager )
-        {
-            manager->Uninstall_Callback(this, wxSOCKET_INPUT);
-            manager->Uninstall_Callback(this, wxSOCKET_OUTPUT);
-        }
-
-        // VZ: CFRunLoopRemoveSource() is probably unnecessary as
-        //     CFSocketInvalidate() seems to do it internally from reading the
-        //     docs, please remove it (and this comment) after testing
-        CFRunLoopRemoveSource(gs_mainRunLoop, m_source, kCFRunLoopCommonModes);
-        CFSocketInvalidate(m_socket);
-
-        CFRelease(m_source);
-        CFRelease(m_socket);
-    }
-
-    // initialize the data associated with the given socket
-    bool Initialize()
-    {
-        // we need a valid Unix socket to create a CFSocket
-        if ( m_fd < 0 )
-            return false;
-
-        CFSocketContext cont;
-        cont.version = 0;               // this currently must be 0
-        cont.info = this;               // pointer passed to our callback
-        cont.retain = NULL;             // no need to retain/release/copy the
-        cont.release = NULL;            //  socket pointer, so all callbacks
-        cont.copyDescription = NULL;    //  can be left NULL
-
-        m_socket = CFSocketCreateWithNative
-                   (
-                        NULL,                   // default allocator
-                        m_fd,
-                        kCFSocketReadCallBack |
-                        kCFSocketWriteCallBack |
-                        kCFSocketConnectCallBack,
-                        SocketCallback,
-                        &cont
-                   );
-        if ( !m_socket )
-            return false;
-
-        m_source = CFSocketCreateRunLoopSource(NULL, m_socket, 0);
-
-        if ( !m_source )
-        {
-            CFRelease(m_socket);
-            return false;
-        }
-
-        CFRunLoopAddSource(gs_mainRunLoop, m_source, kCFRunLoopCommonModes);
-
-        return true;
-    }
-
-    static void SocketCallback(CFSocketRef WXUNUSED(s),
-                               CFSocketCallBackType callbackType,
-                               CFDataRef WXUNUSED(address),
-                               const void* data,
-                               void* info)
-    {
-        wxSocketImplMac * const socket = static_cast<wxSocketImplMac *>(info);
-
-        switch (callbackType)
-        {
-            case kCFSocketConnectCallBack:
-                wxASSERT(!socket->m_server);
-                // KH: If data is non-NULL, the connect failed, do not call Detected_Write,
-                // which will only end up creating a spurious connect event because the
-                // call to getsocketopt SO_ERROR inexplicably returns no error.
-                // The change in behavior cannot be traced to any particular commit or
-                // timeframe so I'm not sure what to think, but after so many hours,
-                // this seems to address the issue and it's time to move on.
-                if (data == NULL)
-                    socket->Detected_Write();
-                break;
-
-            case kCFSocketReadCallBack:
-                socket->Detected_Read();
-                break;
-
-            case kCFSocketWriteCallBack:
-                socket->Detected_Write();
-                break;
-
-            default:
-                wxFAIL_MSG( "unexpected socket callback" );
-        }
-    }
-
-    CFSocketRef m_socket;
-    CFRunLoopSourceRef m_source;
-
-    DECLARE_NO_COPY_CLASS(wxSocketImplMac)
-};
-
-} // anonymous namespace
-
-
-// ----------------------------------------------------------------------------
-// CoreFoundation implementation of wxSocketManager
-// ----------------------------------------------------------------------------
-
-class wxSocketManagerMac : public wxSocketManager
-{
-public:
-    virtual bool OnInit();
-    virtual void OnExit();
-
-    virtual wxSocketImpl *CreateSocket(wxSocketBase& wxsocket)
-    {
-        return new wxSocketImplMac(wxsocket);
-    }
-
-    virtual void Install_Callback(wxSocketImpl *socket, wxSocketNotify event);
-    virtual void Uninstall_Callback(wxSocketImpl *socket, wxSocketNotify event);
-
-private:
-    // return CFSocket callback mask corresponding to the given event (the
-    // socket parameter is needed because some events are interpreted
-    // differently depending on whether they happen on a server or on a client
-    // socket)
-    static int GetCFCallback(wxSocketImpl *socket, wxSocketNotify event);
-};
-
-bool wxSocketManagerMac::OnInit()
-{
-    // No need to store the main loop again
-    if (gs_mainRunLoop != NULL)
-        return true;
-
-    // Get the loop for the main thread so our events will actually fire.
-    // The common socket.cpp code will assert if initialize is called from a
-    // secondary thread, otherwise Mac would have the same problems as MSW
-    gs_mainRunLoop = CFRunLoopGetCurrent();
-    if ( !gs_mainRunLoop )
-        return false;
-
-    CFRetain(gs_mainRunLoop);
-
-    return true;
-}
-
-void wxSocketManagerMac::OnExit()
-{
-    // Release the reference count, and set the reference back to NULL
-    CFRelease(gs_mainRunLoop);
-    gs_mainRunLoop = NULL;
-}
-
-/* static */
-int wxSocketManagerMac::GetCFCallback(wxSocketImpl *socket, wxSocketNotify event)
-{
-    switch ( event )
-    {
-        case wxSOCKET_CONNECTION:
-            return socket->m_server ? kCFSocketReadCallBack
-                                    : kCFSocketConnectCallBack;
-
-        case wxSOCKET_LOST:
-        case wxSOCKET_INPUT:
-            return kCFSocketReadCallBack;
-
-        case wxSOCKET_OUTPUT:
-            return kCFSocketWriteCallBack;
-
-        case wxSOCKET_MAX_EVENT:
-            wxFAIL_MSG( "invalid wxSocketNotify" );
-            return 0;
-
-        default:
-            wxFAIL_MSG( "unknown wxSocketNotify" );
-            return 0;
-    }
-}
-
-void wxSocketManagerMac::Install_Callback(wxSocketImpl *socket_,
-                                          wxSocketNotify event)
-{
-    wxSocketImplMac * const socket = static_cast<wxSocketImplMac *>(socket_);
-
-    CFSocketEnableCallBacks(socket->GetSocket(), GetCFCallback(socket, event));
-}
-
-void wxSocketManagerMac::Uninstall_Callback(wxSocketImpl *socket_,
-                                            wxSocketNotify event)
-{
-    wxSocketImplMac * const socket = static_cast<wxSocketImplMac *>(socket_);
-
-    CFSocketDisableCallBacks(socket->GetSocket(), GetCFCallback(socket, event));
-}
-
-// set the wxBase variable to point to our wxSocketManager implementation
-//
-// see comments in wx/apptrait.h for the explanation of why do we do it
-// like this
-static struct ManagerSetter
-{
-    ManagerSetter()
-    {
-        static wxSocketManagerMac s_manager;
-        wxAppTraits::SetDefaultSocketManager(&s_manager);
-    }
-} gs_managerSetter;
-
-#endif // wxUSE_SOCKETS
diff --git a/src/osx/core/sockosx.cpp b/src/osx/core/sockosx.cpp
new file mode 100644 (file)
index 0000000..08dbd21
--- /dev/null
@@ -0,0 +1,271 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        osx/core/gsockosx.cpp
+// Purpose:     wxSocketImpl implementation for OS X
+// Authors:     Brian Victor, Vadim Zeitlin
+// Created:     February 2002
+// RCS-ID:      $Id$
+// Copyright:   (c) 2002 Brian Victor
+//              (c) 2008 Vadim Zeitlin
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#include "wx/wxprec.h"
+
+#if wxUSE_SOCKETS
+
+#include "wx/private/socket.h"
+#include "wx/unix/private/sockunix.h"
+#include "wx/apptrait.h"
+
+#include <CoreFoundation/CoreFoundation.h>
+
+namespace
+{
+
+// ----------------------------------------------------------------------------
+// global variables
+// ----------------------------------------------------------------------------
+
+// Sockets must use the event loop to monitor the events so we store a
+// reference to the main thread event loop here
+static CFRunLoopRef gs_mainRunLoop = NULL;
+
+// ----------------------------------------------------------------------------
+// Mac-specific socket implementation
+// ----------------------------------------------------------------------------
+
+class wxSocketImplMac : public wxSocketImplUnix
+{
+public:
+    wxSocketImplMac(wxSocketBase& wxsocket)
+        : wxSocketImplUnix(wxsocket)
+    {
+        m_socket = NULL;
+        m_source = NULL;
+    }
+
+    virtual ~wxSocketImplMac()
+    {
+        wxASSERT_MSG( !m_source && !m_socket, "forgot to call Close()?" );
+    }
+
+    // get the underlying socket: creates it on demand
+    CFSocketRef GetSocket() /* const */
+    {
+        if ( !m_socket )
+            Initialize();
+
+        return m_socket;
+    }
+
+private:
+    virtual void DoClose()
+    {
+        wxSocketManager * const manager = wxSocketManager::Get();
+        if ( manager )
+        {
+            manager->Uninstall_Callback(this, wxSOCKET_INPUT);
+            manager->Uninstall_Callback(this, wxSOCKET_OUTPUT);
+        }
+
+        // VZ: CFRunLoopRemoveSource() is probably unnecessary as
+        //     CFSocketInvalidate() seems to do it internally from reading the
+        //     docs, please remove it (and this comment) after testing
+        CFRunLoopRemoveSource(gs_mainRunLoop, m_source, kCFRunLoopCommonModes);
+        CFSocketInvalidate(m_socket);
+
+        CFRelease(m_source);
+        CFRelease(m_socket);
+    }
+
+    // initialize the data associated with the given socket
+    bool Initialize()
+    {
+        // we need a valid Unix socket to create a CFSocket
+        if ( m_fd < 0 )
+            return false;
+
+        CFSocketContext cont;
+        cont.version = 0;               // this currently must be 0
+        cont.info = this;               // pointer passed to our callback
+        cont.retain = NULL;             // no need to retain/release/copy the
+        cont.release = NULL;            //  socket pointer, so all callbacks
+        cont.copyDescription = NULL;    //  can be left NULL
+
+        m_socket = CFSocketCreateWithNative
+                   (
+                        NULL,                   // default allocator
+                        m_fd,
+                        kCFSocketReadCallBack |
+                        kCFSocketWriteCallBack |
+                        kCFSocketConnectCallBack,
+                        SocketCallback,
+                        &cont
+                   );
+        if ( !m_socket )
+            return false;
+
+        m_source = CFSocketCreateRunLoopSource(NULL, m_socket, 0);
+
+        if ( !m_source )
+        {
+            CFRelease(m_socket);
+            return false;
+        }
+
+        CFRunLoopAddSource(gs_mainRunLoop, m_source, kCFRunLoopCommonModes);
+
+        return true;
+    }
+
+    static void SocketCallback(CFSocketRef WXUNUSED(s),
+                               CFSocketCallBackType callbackType,
+                               CFDataRef WXUNUSED(address),
+                               const void* data,
+                               void* info)
+    {
+        wxSocketImplMac * const socket = static_cast<wxSocketImplMac *>(info);
+
+        switch (callbackType)
+        {
+            case kCFSocketConnectCallBack:
+                wxASSERT(!socket->m_server);
+                // KH: If data is non-NULL, the connect failed, do not call Detected_Write,
+                // which will only end up creating a spurious connect event because the
+                // call to getsocketopt SO_ERROR inexplicably returns no error.
+                // The change in behavior cannot be traced to any particular commit or
+                // timeframe so I'm not sure what to think, but after so many hours,
+                // this seems to address the issue and it's time to move on.
+                if (data == NULL)
+                    socket->Detected_Write();
+                break;
+
+            case kCFSocketReadCallBack:
+                socket->Detected_Read();
+                break;
+
+            case kCFSocketWriteCallBack:
+                socket->Detected_Write();
+                break;
+
+            default:
+                wxFAIL_MSG( "unexpected socket callback" );
+        }
+    }
+
+    CFSocketRef m_socket;
+    CFRunLoopSourceRef m_source;
+
+    DECLARE_NO_COPY_CLASS(wxSocketImplMac)
+};
+
+} // anonymous namespace
+
+
+// ----------------------------------------------------------------------------
+// CoreFoundation implementation of wxSocketManager
+// ----------------------------------------------------------------------------
+
+class wxSocketManagerMac : public wxSocketManager
+{
+public:
+    virtual bool OnInit();
+    virtual void OnExit();
+
+    virtual wxSocketImpl *CreateSocket(wxSocketBase& wxsocket)
+    {
+        return new wxSocketImplMac(wxsocket);
+    }
+
+    virtual void Install_Callback(wxSocketImpl *socket, wxSocketNotify event);
+    virtual void Uninstall_Callback(wxSocketImpl *socket, wxSocketNotify event);
+
+private:
+    // return CFSocket callback mask corresponding to the given event (the
+    // socket parameter is needed because some events are interpreted
+    // differently depending on whether they happen on a server or on a client
+    // socket)
+    static int GetCFCallback(wxSocketImpl *socket, wxSocketNotify event);
+};
+
+bool wxSocketManagerMac::OnInit()
+{
+    // No need to store the main loop again
+    if (gs_mainRunLoop != NULL)
+        return true;
+
+    // Get the loop for the main thread so our events will actually fire.
+    // The common socket.cpp code will assert if initialize is called from a
+    // secondary thread, otherwise Mac would have the same problems as MSW
+    gs_mainRunLoop = CFRunLoopGetCurrent();
+    if ( !gs_mainRunLoop )
+        return false;
+
+    CFRetain(gs_mainRunLoop);
+
+    return true;
+}
+
+void wxSocketManagerMac::OnExit()
+{
+    // Release the reference count, and set the reference back to NULL
+    CFRelease(gs_mainRunLoop);
+    gs_mainRunLoop = NULL;
+}
+
+/* static */
+int wxSocketManagerMac::GetCFCallback(wxSocketImpl *socket, wxSocketNotify event)
+{
+    switch ( event )
+    {
+        case wxSOCKET_CONNECTION:
+            return socket->m_server ? kCFSocketReadCallBack
+                                    : kCFSocketConnectCallBack;
+
+        case wxSOCKET_LOST:
+        case wxSOCKET_INPUT:
+            return kCFSocketReadCallBack;
+
+        case wxSOCKET_OUTPUT:
+            return kCFSocketWriteCallBack;
+
+        case wxSOCKET_MAX_EVENT:
+            wxFAIL_MSG( "invalid wxSocketNotify" );
+            return 0;
+
+        default:
+            wxFAIL_MSG( "unknown wxSocketNotify" );
+            return 0;
+    }
+}
+
+void wxSocketManagerMac::Install_Callback(wxSocketImpl *socket_,
+                                          wxSocketNotify event)
+{
+    wxSocketImplMac * const socket = static_cast<wxSocketImplMac *>(socket_);
+
+    CFSocketEnableCallBacks(socket->GetSocket(), GetCFCallback(socket, event));
+}
+
+void wxSocketManagerMac::Uninstall_Callback(wxSocketImpl *socket_,
+                                            wxSocketNotify event)
+{
+    wxSocketImplMac * const socket = static_cast<wxSocketImplMac *>(socket_);
+
+    CFSocketDisableCallBacks(socket->GetSocket(), GetCFCallback(socket, event));
+}
+
+// set the wxBase variable to point to our wxSocketManager implementation
+//
+// see comments in wx/apptrait.h for the explanation of why do we do it
+// like this
+static struct ManagerSetter
+{
+    ManagerSetter()
+    {
+        static wxSocketManagerMac s_manager;
+        wxAppTraits::SetDefaultSocketManager(&s_manager);
+    }
+} gs_managerSetter;
+
+#endif // wxUSE_SOCKETS
diff --git a/src/unix/gsocket.cpp b/src/unix/gsocket.cpp
deleted file mode 100644 (file)
index 2bdfa8d..0000000
+++ /dev/null
@@ -1,1691 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name:        src/unix/gsocket.cpp
-// Purpose:     wxSocketImpl implementation for Unix systems
-// Authors:     Guilhem Lavaux, Guillermo Rodriguez Garcia, David Elliott,
-//              Vadim Zeitlin
-// Created:     April 1997
-// RCS-ID:      $Id$
-// Copyright:   (c) 1997 Guilhem Lavaux
-//              (c) 2008 Vadim Zeitlin
-// Licence:     wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-
-#include "wx/wxprec.h"
-
-#if wxUSE_SOCKETS
-
-#include "wx/private/gsocket.h"
-
-#include "wx/private/fd.h"
-#include "wx/private/socket.h"
-#include "wx/private/gsocketiohandler.h"
-
-#if defined(__VISAGECPP__)
-#define BSD_SELECT /* use Berkeley Sockets select */
-#endif
-
-#if defined(__WATCOMC__)
-#include <errno.h>
-#include <nerrno.h>
-#endif
-
-#include <assert.h>
-#include <sys/types.h>
-#ifdef __VISAGECPP__
-#include <string.h>
-#include <sys/time.h>
-#include <types.h>
-#include <netinet/in.h>
-#endif
-#include <netdb.h>
-#include <sys/ioctl.h>
-
-#ifdef HAVE_SYS_SELECT_H
-#   include <sys/select.h>
-#endif
-
-#ifdef __VMS__
-#include <socket.h>
-struct sockaddr_un
-{
-    u_char  sun_len;        /* sockaddr len including null */
-    u_char  sun_family;     /* AF_UNIX */
-    char    sun_path[108];  /* path name (gag) */
-};
-#else
-#include <sys/socket.h>
-#include <sys/un.h>
-#endif
-
-#ifndef __VISAGECPP__
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#else
-#include <nerrno.h>
-#  if __IBMCPP__ < 400
-#include <machine/endian.h>
-#include <socket.h>
-#include <ioctl.h>
-#include <select.h>
-#include <unistd.h>
-
-#define EBADF   SOCEBADF
-
-#    ifdef min
-#    undef min
-#    endif
-#  else
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/select.h>
-
-#define close(a) soclose(a)
-#define select(a,b,c,d,e) bsdselect(a,b,c,d,e)
-int _System bsdselect(int,
-                      struct fd_set *,
-                      struct fd_set *,
-                      struct fd_set *,
-                      struct timeval *);
-int _System soclose(int);
-#  endif
-#endif
-#ifdef __EMX__
-#include <sys/select.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <ctype.h>
-#ifdef sun
-#  include <sys/filio.h>
-#endif
-#ifdef sgi
-#  include <bstring.h>
-#endif
-#ifdef _AIX
-#  include <strings.h>
-#endif
-#include <signal.h>
-
-#ifndef WX_SOCKLEN_T
-
-#ifdef VMS
-#  define WX_SOCKLEN_T unsigned int
-#else
-#  ifdef __GLIBC__
-#    if __GLIBC__ == 2
-#      define WX_SOCKLEN_T socklen_t
-#    endif
-#  elif defined(__WXMAC__)
-#    define WX_SOCKLEN_T socklen_t
-#  else
-#    define WX_SOCKLEN_T int
-#  endif
-#endif
-
-#endif /* SOCKLEN_T */
-
-#ifndef SOCKOPTLEN_T
-#define SOCKOPTLEN_T WX_SOCKLEN_T
-#endif
-
-/* UnixWare reportedly needs this for FIONBIO definition */
-#ifdef __UNIXWARE__
-#include <sys/filio.h>
-#endif
-
-/*
- * INADDR_BROADCAST is identical to INADDR_NONE which is not defined
- * on all systems. INADDR_BROADCAST should be fine to indicate an error.
- */
-#ifndef INADDR_NONE
-#define INADDR_NONE INADDR_BROADCAST
-#endif
-
-#if defined(__VISAGECPP__) || defined(__WATCOMC__)
-
-    #define MASK_SIGNAL() {
-    #define UNMASK_SIGNAL() }
-
-#else
-    extern "C" { typedef void (*wxSigHandler)(int); }
-
-    #define MASK_SIGNAL()                       \
-    {                                           \
-        wxSigHandler old_handler = signal(SIGPIPE, SIG_IGN);
-
-    #define UNMASK_SIGNAL()                     \
-        signal(SIGPIPE, old_handler);           \
-    }
-
-#endif
-
-/* If a SIGPIPE is issued by a socket call on a remotely closed socket,
-   the program will "crash" unless it explicitly handles the SIGPIPE.
-   By using MSG_NOSIGNAL, the SIGPIPE is suppressed. Later, we will
-   use SO_NOSIGPIPE (if available), the BSD equivalent. */
-#ifdef MSG_NOSIGNAL
-#  define GSOCKET_MSG_NOSIGNAL MSG_NOSIGNAL
-#else /* MSG_NOSIGNAL not available (FreeBSD including OS X) */
-#  define GSOCKET_MSG_NOSIGNAL 0
-#endif /* MSG_NOSIGNAL */
-
-#if wxUSE_THREADS && (defined(HAVE_GETHOSTBYNAME) || defined(HAVE_GETSERVBYNAME))
-#  include "wx/thread.h"
-#endif
-
-#if defined(HAVE_GETHOSTBYNAME)
-static struct hostent * deepCopyHostent(struct hostent *h,
-                                       const struct hostent *he,
-                                       char *buffer, int size, int *err)
-{
-  /* copy old structure */
-  memcpy(h, he, sizeof(struct hostent));
-
-  /* copy name */
-  int len = strlen(h->h_name);
-  if (len > size)
-  {
-    *err = ENOMEM;
-    return NULL;
-  }
-  memcpy(buffer, h->h_name, len);
-  buffer[len] = '\0';
-  h->h_name = buffer;
-
-  /* track position in the buffer */
-  int pos = len + 1;
-
-  /* reuse len to store address length */
-  len = h->h_length;
-
-  /* ensure pointer alignment */
-  unsigned int misalign = sizeof(char *) - pos%sizeof(char *);
-  if(misalign < sizeof(char *))
-    pos += misalign;
-
-  /* leave space for pointer list */
-  char **p = h->h_addr_list, **q;
-  char **h_addr_list = (char **)(buffer + pos);
-  while(*(p++) != 0)
-    pos += sizeof(char *);
-
-  /* copy addresses and fill new pointer list */
-  for (p = h->h_addr_list, q = h_addr_list; *p != 0; p++, q++)
-  {
-    if (size < pos + len)
-    {
-      *err = ENOMEM;
-      return NULL;
-    }
-    memcpy(buffer + pos, *p, len); /* copy content */
-    *q = buffer + pos; /* set copied pointer to copied content */
-    pos += len;
-  }
-  *++q = 0; /* null terminate the pointer list */
-  h->h_addr_list = h_addr_list; /* copy pointer to pointers */
-
-  /* ensure word alignment of pointers */
-  misalign = sizeof(char *) - pos%sizeof(char *);
-  if(misalign < sizeof(char *))
-    pos += misalign;
-
-  /* leave space for pointer list */
-  p = h->h_aliases;
-  char **h_aliases = (char **)(buffer + pos);
-  while(*(p++) != 0)
-    pos += sizeof(char *);
-
-  /* copy aliases and fill new pointer list */
-  for (p = h->h_aliases, q = h_aliases; *p != 0; p++, q++)
-  {
-    len = strlen(*p);
-    if (size <= pos + len)
-    {
-      *err = ENOMEM;
-      return NULL;
-    }
-    memcpy(buffer + pos, *p, len); /* copy content */
-    buffer[pos + len] = '\0';
-    *q = buffer + pos; /* set copied pointer to copied content */
-    pos += len + 1;
-  }
-  *++q = 0; /* null terminate the pointer list */
-  h->h_aliases = h_aliases; /* copy pointer to pointers */
-
-  return h;
-}
-#endif
-
-#if defined(HAVE_GETHOSTBYNAME) && wxUSE_THREADS
-static wxMutex nameLock;
-#endif
-struct hostent * wxGethostbyname_r(const char *hostname, struct hostent *h,
-                                  void *buffer, int size, int *err)
-
-{
-  struct hostent *he = NULL;
-  *err = 0;
-#if defined(HAVE_FUNC_GETHOSTBYNAME_R_6)
-  if (gethostbyname_r(hostname, h, (char*)buffer, size, &he, err))
-    he = NULL;
-#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5)
-  he = gethostbyname_r(hostname, h, (char*)buffer, size, err);
-#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
-  if (gethostbyname_r(hostname, h, (struct hostent_data*) buffer))
-  {
-    he = NULL;
-    *err = h_errno;
-  }
-  else
-    he = h;
-#elif defined(HAVE_GETHOSTBYNAME)
-#if wxUSE_THREADS
-  wxMutexLocker locker(nameLock);
-#endif
-  he = gethostbyname(hostname);
-  if (!he)
-    *err = h_errno;
-  else
-    he = deepCopyHostent(h, he, (char*)buffer, size, err);
-#endif
-  return he;
-}
-
-#if defined(HAVE_GETHOSTBYNAME) && wxUSE_THREADS
-static wxMutex addrLock;
-#endif
-struct hostent * wxGethostbyaddr_r(const char *addr_buf, int buf_size,
-                                  int proto, struct hostent *h,
-                                  void *buffer, int size, int *err)
-{
-  struct hostent *he = NULL;
-  *err = 0;
-#if defined(HAVE_FUNC_GETHOSTBYNAME_R_6)
-  if (gethostbyaddr_r(addr_buf, buf_size, proto, h,
-                     (char*)buffer, size, &he, err))
-    he = NULL;
-#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5)
-  he = gethostbyaddr_r(addr_buf, buf_size, proto, h, (char*)buffer, size, err);
-#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
-  if (gethostbyaddr_r(addr_buf, buf_size, proto, h,
-                       (struct hostent_data*) buffer))
-  {
-    he = NULL;
-    *err = h_errno;
-  }
-  else
-    he = h;
-#elif defined(HAVE_GETHOSTBYNAME)
-#if wxUSE_THREADS
-  wxMutexLocker locker(addrLock);
-#endif
-  he = gethostbyaddr(addr_buf, buf_size, proto);
-  if (!he)
-    *err = h_errno;
-  else
-    he = deepCopyHostent(h, he, (char*)buffer, size, err);
-#endif
-  return he;
-}
-
-#if defined(HAVE_GETSERVBYNAME)
-static struct servent * deepCopyServent(struct servent *s,
-                                       const struct servent *se,
-                                       char *buffer, int size)
-{
-  /* copy plain old structure */
-  memcpy(s, se, sizeof(struct servent));
-
-  /* copy name */
-  int len = strlen(s->s_name);
-  if (len >= size)
-  {
-    return NULL;
-  }
-  memcpy(buffer, s->s_name, len);
-  buffer[len] = '\0';
-  s->s_name = buffer;
-
-  /* track position in the buffer */
-  int pos = len + 1;
-
-  /* copy protocol */
-  len = strlen(s->s_proto);
-  if (pos + len >= size)
-  {
-    return NULL;
-  }
-  memcpy(buffer + pos, s->s_proto, len);
-  buffer[pos + len] = '\0';
-  s->s_proto = buffer + pos;
-
-  /* track position in the buffer */
-  pos += len + 1;
-
-  /* ensure pointer alignment */
-  unsigned int misalign = sizeof(char *) - pos%sizeof(char *);
-  if(misalign < sizeof(char *))
-    pos += misalign;
-
-  /* leave space for pointer list */
-  char **p = s->s_aliases, **q;
-  char **s_aliases = (char **)(buffer + pos);
-  while(*(p++) != 0)
-    pos += sizeof(char *);
-
-  /* copy addresses and fill new pointer list */
-  for (p = s->s_aliases, q = s_aliases; *p != 0; p++, q++){
-    len = strlen(*p);
-    if (size <= pos + len)
-    {
-      return NULL;
-    }
-    memcpy(buffer + pos, *p, len); /* copy content */
-    buffer[pos + len] = '\0';
-    *q = buffer + pos; /* set copied pointer to copied content */
-    pos += len + 1;
-  }
-  *++q = 0; /* null terminate the pointer list */
-  s->s_aliases = s_aliases; /* copy pointer to pointers */
-  return s;
-}
-#endif
-
-#if defined(HAVE_GETSERVBYNAME) && wxUSE_THREADS
-static wxMutex servLock;
-#endif
-struct servent *wxGetservbyname_r(const char *port, const char *protocol,
-                                 struct servent *serv, void *buffer, int size)
-{
-  struct servent *se = NULL;
-#if defined(HAVE_FUNC_GETSERVBYNAME_R_6)
-  if (getservbyname_r(port, protocol, serv, (char*)buffer, size, &se))
-    se = NULL;
-#elif defined(HAVE_FUNC_GETSERVBYNAME_R_5)
-  se = getservbyname_r(port, protocol, serv, (char*)buffer, size);
-#elif defined(HAVE_FUNC_GETSERVBYNAME_R_4)
-  if (getservbyname_r(port, protocol, serv, (struct servent_data*) buffer))
-    se = NULL;
-  else
-    se = serv;
-#elif defined(HAVE_GETSERVBYNAME)
-#if wxUSE_THREADS
-  wxMutexLocker locker(servLock);
-#endif
-  se = getservbyname(port, protocol);
-  if (se)
-    se = deepCopyServent(serv, se, (char*)buffer, size);
-#endif
-  return se;
-}
-
-/* debugging helpers */
-#ifdef __GSOCKET_DEBUG__
-#  define SOCKET_DEBUG(args) printf args
-#else
-#  define SOCKET_DEBUG(args)
-#endif /* __GSOCKET_DEBUG__ */
-
-/* Constructors / Destructors for wxSocketImplUnix */
-
-wxSocketImplUnix::wxSocketImplUnix(wxSocketBase& wxsocket)
-    : wxSocketImpl(wxsocket)
-{
-    m_fds[0] =
-    m_fds[1] = -1;
-
-    m_use_events = false;
-}
-
-/*
- *  Disallow further read/write operations on this socket, close
- *  the fd and disable all callbacks.
- */
-void wxSocketImplUnix::Shutdown()
-{
-    /* Don't allow events to fire after socket has been closed */
-    DisableEvents();
-
-    wxSocketImpl::Shutdown();
-}
-
-/*
- *  Waits for an incoming client connection. Returns a pointer to
- *  a wxSocketImplUnix object, or NULL if there was an error, in which case
- *  the last error field will be updated for the calling wxSocketImplUnix.
- *
- *  Error codes (set in the calling wxSocketImplUnix)
- *    wxSOCKET_INVSOCK    - the socket is not valid or not a server.
- *    wxSOCKET_TIMEDOUT   - timeout, no incoming connections.
- *    wxSOCKET_WOULDBLOCK - the call would block and the socket is nonblocking.
- *    wxSOCKET_MEMERR     - couldn't allocate memory.
- *    wxSOCKET_IOERR      - low-level error.
- */
-wxSocketImpl *wxSocketImplUnix::WaitConnection(wxSocketBase& wxsocket)
-{
-  wxSockAddr from;
-  WX_SOCKLEN_T fromlen = sizeof(from);
-  wxSocketImpl *connection;
-  wxSocketError err;
-  int arg = 1;
-
-  /* If the socket has already been created, we exit immediately */
-  if (m_fd == INVALID_SOCKET || !m_server)
-  {
-    m_error = wxSOCKET_INVSOCK;
-    return NULL;
-  }
-
-  /* Create a wxSocketImplUnix object for the new connection */
-  connection = wxSocketImplUnix::Create(wxsocket);
-
-  if (!connection)
-  {
-    m_error = wxSOCKET_MEMERR;
-    return NULL;
-  }
-
-  /* Wait for a connection (with timeout) */
-  if (Input_Timeout() == wxSOCKET_TIMEDOUT)
-  {
-    delete connection;
-    /* m_error set by Input_Timeout */
-    return NULL;
-  }
-
-  connection->m_fd = accept(m_fd, (sockaddr*)&from, (WX_SOCKLEN_T *) &fromlen);
-
-  /* Reenable CONNECTION events */
-  EnableEvent(wxSOCKET_CONNECTION);
-
-  if (connection->m_fd == INVALID_SOCKET)
-  {
-    if (errno == EWOULDBLOCK)
-      m_error = wxSOCKET_WOULDBLOCK;
-    else
-      m_error = wxSOCKET_IOERR;
-
-    delete connection;
-    return NULL;
-  }
-
-  /* Initialize all fields */
-  connection->m_server   = false;
-  connection->m_stream   = true;
-
-  /* Setup the peer address field */
-  connection->m_peer = GAddress_new();
-  if (!connection->m_peer)
-  {
-    delete connection;
-    m_error = wxSOCKET_MEMERR;
-    return NULL;
-  }
-
-  err = _GAddress_translate_from(connection->m_peer, (sockaddr*)&from, fromlen);
-  if (err != wxSOCKET_NOERROR)
-  {
-    delete connection;
-    m_error = err;
-    return NULL;
-  }
-
-#if defined(__EMX__) || defined(__VISAGECPP__)
-  ioctl(connection->m_fd, FIONBIO, (char*)&arg, sizeof(arg));
-#else
-  ioctl(connection->m_fd, FIONBIO, &arg);
-#endif
-  if (m_use_events)
-    connection->Notify(true);
-
-  return connection;
-}
-
-void wxSocketImplUnix::Notify(bool flag)
-{
-    if (flag == m_use_events)
-        return;
-    m_use_events = flag;
-    DoEnableEvents(flag);
-}
-
-void wxSocketImplUnix::DoEnableEvents(bool flag)
-{
-    wxSocketManager * const manager = wxSocketManager::Get();
-    if ( flag )
-    {
-        manager->Install_Callback(this, wxSOCKET_INPUT);
-        manager->Install_Callback(this, wxSOCKET_OUTPUT);
-    }
-    else // off
-    {
-        manager->Uninstall_Callback(this, wxSOCKET_INPUT);
-        manager->Uninstall_Callback(this, wxSOCKET_OUTPUT);
-    }
-}
-
-wxSocketError wxSocketImplUnix::DoHandleConnect(int ret)
-{
-  /* We only call EnableEvents() if we know we aren't shutting down the socket.
-   * NB: EnableEvents() needs to be called whether the socket is blocking or
-   * non-blocking, it just shouldn't be called prior to knowing there is a
-   * connection _if_ blocking sockets are being used.
-   * If connect above returns 0, we are already connected and need to make the
-   * call to EnableEvents() now.
-   */
-  if ( m_non_blocking || (ret == 0) )
-    EnableEvents();
-
-  if (ret == -1)
-  {
-    const int err = errno;
-
-    /* If connect failed with EINPROGRESS and the wxSocketImplUnix object
-     * is in blocking mode, we select() for the specified timeout
-     * checking for writability to see if the connection request
-     * completes.
-     */
-    if ((err == EINPROGRESS) && (!m_non_blocking))
-    {
-      if (Output_Timeout() == wxSOCKET_TIMEDOUT)
-      {
-        Close();
-        /* m_error is set in Output_Timeout */
-        return wxSOCKET_TIMEDOUT;
-      }
-      else
-      {
-        int error;
-        SOCKOPTLEN_T len = sizeof(error);
-
-        getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (char*) &error, &len);
-        EnableEvents();
-
-        if (!error)
-          return wxSOCKET_NOERROR;
-      }
-    }
-
-    /* If connect failed with EINPROGRESS and the wxSocketImplUnix object
-     * is set to nonblocking, we set m_error to wxSOCKET_WOULDBLOCK
-     * (and return wxSOCKET_WOULDBLOCK) but we don't close the socket;
-     * this way if the connection completes, a wxSOCKET_CONNECTION
-     * event will be generated, if enabled.
-     */
-    if ((err == EINPROGRESS) && (m_non_blocking))
-    {
-      m_establishing = true;
-      m_error = wxSOCKET_WOULDBLOCK;
-      return wxSOCKET_WOULDBLOCK;
-    }
-
-    /* If connect failed with an error other than EINPROGRESS,
-     * then the call to Connect has failed.
-     */
-    Close();
-    m_error = wxSOCKET_IOERR;
-
-    return wxSOCKET_IOERR;
-  }
-
-  return wxSOCKET_NOERROR;
-}
-
-/* Generic IO */
-
-/* Like recv(), send(), ... */
-int wxSocketImplUnix::Read(char *buffer, int size)
-{
-  int ret;
-
-  if (m_fd == INVALID_SOCKET || m_server)
-  {
-    m_error = wxSOCKET_INVSOCK;
-    return -1;
-  }
-
-  /* Disable events during query of socket status */
-  DisableEvent(wxSOCKET_INPUT);
-
-  /* If the socket is blocking, wait for data (with a timeout) */
-  if (Input_Timeout() == wxSOCKET_TIMEDOUT) {
-    m_error = wxSOCKET_TIMEDOUT;
-    /* Don't return here immediately, otherwise socket events would not be
-     * re-enabled! */
-    ret = -1;
-  }
-  else
-  {
-    /* Read the data */
-    if (m_stream)
-      ret = Recv_Stream(buffer, size);
-    else
-      ret = Recv_Dgram(buffer, size);
-
-    /*
-     * If recv returned zero for a TCP socket (if m_stream == NULL, it's an UDP
-     * socket and empty datagrams are possible), then the connection has been
-     * gracefully closed.
-     *
-     * Otherwise, recv has returned an error (-1), in which case we have lost
-     * the socket only if errno does _not_ indicate that there may be more data
-     * to read.
-     */
-    if ((ret == 0) && m_stream)
-    {
-      /* Make sure wxSOCKET_LOST event gets sent and shut down the socket */
-      if (m_use_events)
-      {
-        m_detected = wxSOCKET_LOST_FLAG;
-        Detected_Read();
-        return 0;
-      }
-    }
-    else if (ret == -1)
-    {
-      if ((errno == EWOULDBLOCK) || (errno == EAGAIN))
-        m_error = wxSOCKET_WOULDBLOCK;
-      else
-        m_error = wxSOCKET_IOERR;
-    }
-  }
-
-  /* Enable events again now that we are done processing */
-  EnableEvent(wxSOCKET_INPUT);
-
-  return ret;
-}
-
-int wxSocketImplUnix::Write(const char *buffer, int size)
-{
-  int ret;
-
-  SOCKET_DEBUG(( "Write #1, size %d\n", size ));
-
-  if (m_fd == INVALID_SOCKET || m_server)
-  {
-    m_error = wxSOCKET_INVSOCK;
-    return -1;
-  }
-
-  SOCKET_DEBUG(( "Write #2, size %d\n", size ));
-
-  /* If the socket is blocking, wait for writability (with a timeout) */
-  if (Output_Timeout() == wxSOCKET_TIMEDOUT)
-    return -1;
-
-  SOCKET_DEBUG(( "Write #3, size %d\n", size ));
-
-  /* Write the data */
-  if (m_stream)
-    ret = Send_Stream(buffer, size);
-  else
-    ret = Send_Dgram(buffer, size);
-
-  SOCKET_DEBUG(( "Write #4, size %d\n", size ));
-
-  if (ret == -1)
-  {
-    if ((errno == EWOULDBLOCK) || (errno == EAGAIN))
-    {
-      m_error = wxSOCKET_WOULDBLOCK;
-      SOCKET_DEBUG(( "Write error WOULDBLOCK\n" ));
-    }
-    else
-    {
-      m_error = wxSOCKET_IOERR;
-      SOCKET_DEBUG(( "Write error IOERR\n" ));
-    }
-
-    /* Only reenable OUTPUT events after an error (just like WSAAsyncSelect
-     * in MSW). Once the first OUTPUT event is received, users can assume
-     * that the socket is writable until a read operation fails. Only then
-     * will further OUTPUT events be posted.
-     */
-    EnableEvent(wxSOCKET_OUTPUT);
-
-    return -1;
-  }
-
-  SOCKET_DEBUG(( "Write #5, size %d ret %d\n", size, ret ));
-
-  return ret;
-}
-
-/* Flags */
-
-void wxSocketImplUnix::EnableEvent(wxSocketNotify event)
-{
-    if (m_use_events)
-    {
-        m_detected &= ~(1 << event);
-        wxSocketManager::Get()->Install_Callback(this, event);
-    }
-}
-
-void wxSocketImplUnix::DisableEvent(wxSocketNotify event)
-{
-    if (m_use_events)
-    {
-        m_detected |= (1 << event);
-        wxSocketManager::Get()->Uninstall_Callback(this, event);
-    }
-}
-
-/*
- *  For blocking sockets, wait until data is available or
- *  until timeout ellapses.
- */
-wxSocketError wxSocketImplUnix::Input_Timeout()
-{
-  fd_set readfds;
-  int ret;
-
-  // Linux select() will overwrite the struct on return so make a copy
-  struct timeval tv = m_timeout;
-
-  if (!m_non_blocking)
-  {
-    wxFD_ZERO(&readfds);
-    wxFD_SET(m_fd, &readfds);
-    ret = select(m_fd + 1, &readfds, NULL, NULL, &tv);
-    if (ret == 0)
-    {
-      SOCKET_DEBUG(( "Input_Timeout, select returned 0\n" ));
-      m_error = wxSOCKET_TIMEDOUT;
-      return wxSOCKET_TIMEDOUT;
-    }
-
-    if (ret == -1)
-    {
-      SOCKET_DEBUG(( "Input_Timeout, select returned -1\n" ));
-      if (errno == EBADF) { SOCKET_DEBUG(( "Invalid file descriptor\n" )); }
-      if (errno == EINTR) { SOCKET_DEBUG(( "A non blocked signal was caught\n" )); }
-      if (errno == EINVAL) { SOCKET_DEBUG(( "The highest number descriptor is negative\n" )); }
-      if (errno == ENOMEM) { SOCKET_DEBUG(( "Not enough memory\n" )); }
-      m_error = wxSOCKET_TIMEDOUT;
-      return wxSOCKET_TIMEDOUT;
-    }
-  }
-
-  return wxSOCKET_NOERROR;
-}
-
-/*
- *  For blocking sockets, wait until data can be sent without
- *  blocking or until timeout ellapses.
- */
-wxSocketError wxSocketImplUnix::Output_Timeout()
-{
-  fd_set writefds;
-  int ret;
-
-  // Linux select() will overwrite the struct on return so make a copy
-  struct timeval tv = m_timeout;
-
-  SOCKET_DEBUG( ("m_non_blocking has: %d\n", (int)m_non_blocking) );
-
-  if (!m_non_blocking)
-  {
-    wxFD_ZERO(&writefds);
-    wxFD_SET(m_fd, &writefds);
-    ret = select(m_fd + 1, NULL, &writefds, NULL, &tv);
-    if (ret == 0)
-    {
-      SOCKET_DEBUG(( "Output_Timeout, select returned 0\n" ));
-      m_error = wxSOCKET_TIMEDOUT;
-      return wxSOCKET_TIMEDOUT;
-    }
-
-    if (ret == -1)
-    {
-      SOCKET_DEBUG(( "Output_Timeout, select returned -1\n" ));
-      if (errno == EBADF) { SOCKET_DEBUG(( "Invalid file descriptor\n" )); }
-      if (errno == EINTR) { SOCKET_DEBUG(( "A non blocked signal was caught\n" )); }
-      if (errno == EINVAL) { SOCKET_DEBUG(( "The highest number descriptor is negative\n" )); }
-      if (errno == ENOMEM) { SOCKET_DEBUG(( "Not enough memory\n" )); }
-      m_error = wxSOCKET_TIMEDOUT;
-      return wxSOCKET_TIMEDOUT;
-    }
-
-    if ( ! wxFD_ISSET(m_fd, &writefds) )
-    {
-        SOCKET_DEBUG(( "Output_Timeout is buggy!\n" ));
-    }
-    else
-    {
-        SOCKET_DEBUG(( "Output_Timeout seems correct\n" ));
-    }
-  }
-  else
-  {
-    SOCKET_DEBUG(( "Output_Timeout, didn't try select!\n" ));
-  }
-
-  return wxSOCKET_NOERROR;
-}
-
-int wxSocketImplUnix::Recv_Stream(char *buffer, int size)
-{
-  int ret;
-  do
-  {
-    ret = recv(m_fd, buffer, size, GSOCKET_MSG_NOSIGNAL);
-  }
-  while (ret == -1 && errno == EINTR); /* Loop until not interrupted */
-
-  return ret;
-}
-
-int wxSocketImplUnix::Recv_Dgram(char *buffer, int size)
-{
-  wxSockAddr from;
-  WX_SOCKLEN_T fromlen = sizeof(from);
-  int ret;
-  wxSocketError err;
-
-  fromlen = sizeof(from);
-
-  do
-  {
-    ret = recvfrom(m_fd, buffer, size, 0, (sockaddr*)&from, (WX_SOCKLEN_T *) &fromlen);
-  }
-  while (ret == -1 && errno == EINTR); /* Loop until not interrupted */
-
-  if (ret == -1)
-    return -1;
-
-  /* Translate a system address into a wxSocketImplUnix address */
-  if (!m_peer)
-  {
-    m_peer = GAddress_new();
-    if (!m_peer)
-    {
-      m_error = wxSOCKET_MEMERR;
-      return -1;
-    }
-  }
-
-  err = _GAddress_translate_from(m_peer, (sockaddr*)&from, fromlen);
-  if (err != wxSOCKET_NOERROR)
-  {
-    GAddress_destroy(m_peer);
-    m_peer  = NULL;
-    m_error = err;
-    return -1;
-  }
-
-  return ret;
-}
-
-int wxSocketImplUnix::Send_Stream(const char *buffer, int size)
-{
-  int ret;
-
-  MASK_SIGNAL();
-
-  do
-  {
-    ret = send(m_fd, (char *)buffer, size, GSOCKET_MSG_NOSIGNAL);
-  }
-  while (ret == -1 && errno == EINTR); /* Loop until not interrupted */
-
-  UNMASK_SIGNAL();
-
-  return ret;
-}
-
-int wxSocketImplUnix::Send_Dgram(const char *buffer, int size)
-{
-  struct sockaddr *addr;
-  int len, ret;
-  wxSocketError err;
-
-  if (!m_peer)
-  {
-    m_error = wxSOCKET_INVADDR;
-    return -1;
-  }
-
-  err = _GAddress_translate_to(m_peer, &addr, &len);
-  if (err != wxSOCKET_NOERROR)
-  {
-    m_error = err;
-    return -1;
-  }
-
-  MASK_SIGNAL();
-
-  do
-  {
-    ret = sendto(m_fd, (char *)buffer, size, 0, addr, len);
-  }
-  while (ret == -1 && errno == EINTR); /* Loop until not interrupted */
-
-  UNMASK_SIGNAL();
-
-  /* Frees memory allocated from _GAddress_translate_to */
-  free(addr);
-
-  return ret;
-}
-
-void wxSocketImplUnix::OnStateChange(wxSocketNotify event)
-{
-    DisableEvent(event);
-    NotifyOnStateChange(event);
-
-    if ( event == wxSOCKET_LOST )
-        Shutdown();
-}
-
-void wxSocketImplUnix::Detected_Read()
-{
-  char c;
-
-  /* Safeguard against straggling call to Detected_Read */
-  if (m_fd == INVALID_SOCKET)
-  {
-    return;
-  }
-
-  /* If we have already detected a LOST event, then don't try
-   * to do any further processing.
-   */
-  if ((m_detected & wxSOCKET_LOST_FLAG) != 0)
-  {
-    m_establishing = false;
-
-    OnStateChange(wxSOCKET_LOST);
-    return;
-  }
-
-  int num =  recv(m_fd, &c, 1, MSG_PEEK | GSOCKET_MSG_NOSIGNAL);
-
-  if (num > 0)
-  {
-    OnStateChange(wxSOCKET_INPUT);
-  }
-  else
-  {
-    if (m_server && m_stream)
-    {
-      OnStateChange(wxSOCKET_CONNECTION);
-    }
-    else if (num == 0)
-    {
-      if (m_stream)
-      {
-        /* graceful shutdown */
-        OnStateChange(wxSOCKET_LOST);
-      }
-      else
-      {
-        /* Empty datagram received */
-        OnStateChange(wxSOCKET_INPUT);
-      }
-    }
-    else
-    {
-      /* Do not throw a lost event in cases where the socket isn't really lost */
-      if ((errno == EWOULDBLOCK) || (errno == EAGAIN) || (errno == EINTR))
-      {
-        OnStateChange(wxSOCKET_INPUT);
-      }
-      else
-      {
-        OnStateChange(wxSOCKET_LOST);
-      }
-    }
-  }
-}
-
-void wxSocketImplUnix::Detected_Write()
-{
-  /* If we have already detected a LOST event, then don't try
-   * to do any further processing.
-   */
-  if ((m_detected & wxSOCKET_LOST_FLAG) != 0)
-  {
-    m_establishing = false;
-
-    OnStateChange(wxSOCKET_LOST);
-    return;
-  }
-
-  if (m_establishing && !m_server)
-  {
-    int error;
-    SOCKOPTLEN_T len = sizeof(error);
-
-    m_establishing = false;
-
-    getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (char*)&error, &len);
-
-    if (error)
-    {
-      OnStateChange(wxSOCKET_LOST);
-    }
-    else
-    {
-      OnStateChange(wxSOCKET_CONNECTION);
-      /* We have to fire this event by hand because CONNECTION (for clients)
-       * and OUTPUT are internally the same and we just disabled CONNECTION
-       * events with the above macro.
-       */
-      OnStateChange(wxSOCKET_OUTPUT);
-    }
-  }
-  else
-  {
-    OnStateChange(wxSOCKET_OUTPUT);
-  }
-}
-
-/*
- * -------------------------------------------------------------------------
- * GAddress
- * -------------------------------------------------------------------------
- */
-
-/* CHECK_ADDRESS verifies that the current address family is either
- * wxSOCKET_NOFAMILY or wxSOCKET_*family*, and if it is wxSOCKET_NOFAMILY, it
- * initalizes it to be a wxSOCKET_*family*. In other cases, it returns
- * an appropiate error code.
- *
- * CHECK_ADDRESS_RETVAL does the same but returning 'retval' on error.
- */
-#define CHECK_ADDRESS(address, family)                              \
-{                                                                   \
-  if (address->m_family == wxSOCKET_NOFAMILY)                          \
-    if (_GAddress_Init_##family(address) != wxSOCKET_NOERROR)          \
-      return address->m_error;                                      \
-  if (address->m_family != wxSOCKET_##family)                          \
-  {                                                                 \
-    address->m_error = wxSOCKET_INVADDR;                               \
-    return wxSOCKET_INVADDR;                                           \
-  }                                                                 \
-}
-
-#define CHECK_ADDRESS_RETVAL(address, family, retval)               \
-{                                                                   \
-  if (address->m_family == wxSOCKET_NOFAMILY)                          \
-    if (_GAddress_Init_##family(address) != wxSOCKET_NOERROR)          \
-      return retval;                                                \
-  if (address->m_family != wxSOCKET_##family)                          \
-  {                                                                 \
-    address->m_error = wxSOCKET_INVADDR;                               \
-    return retval;                                                  \
-  }                                                                 \
-}
-
-
-GAddress *GAddress_new(void)
-{
-  GAddress *address;
-
-  if ((address = (GAddress *) malloc(sizeof(GAddress))) == NULL)
-    return NULL;
-
-  address->m_family  = wxSOCKET_NOFAMILY;
-  address->m_addr    = NULL;
-  address->m_len     = 0;
-
-  return address;
-}
-
-GAddress *GAddress_copy(GAddress *address)
-{
-  GAddress *addr2;
-
-  assert(address != NULL);
-
-  if ((addr2 = (GAddress *) malloc(sizeof(GAddress))) == NULL)
-    return NULL;
-
-  memcpy(addr2, address, sizeof(GAddress));
-
-  if (address->m_addr && address->m_len > 0)
-  {
-    addr2->m_addr = (struct sockaddr *)malloc(addr2->m_len);
-    if (addr2->m_addr == NULL)
-    {
-      free(addr2);
-      return NULL;
-    }
-    memcpy(addr2->m_addr, address->m_addr, addr2->m_len);
-  }
-
-  return addr2;
-}
-
-void GAddress_destroy(GAddress *address)
-{
-  assert(address != NULL);
-
-  if (address->m_addr)
-    free(address->m_addr);
-
-  free(address);
-}
-
-void GAddress_SetFamily(GAddress *address, GAddressType type)
-{
-  assert(address != NULL);
-
-  address->m_family = type;
-}
-
-GAddressType GAddress_GetFamily(GAddress *address)
-{
-  assert(address != NULL);
-
-  return address->m_family;
-}
-
-wxSocketError _GAddress_translate_from(GAddress *address,
-                                      struct sockaddr *addr, int len)
-{
-  address->m_realfamily = addr->sa_family;
-  switch (addr->sa_family)
-  {
-    case AF_INET:
-      address->m_family = wxSOCKET_INET;
-      break;
-    case AF_UNIX:
-      address->m_family = wxSOCKET_UNIX;
-      break;
-#if wxUSE_IPV6
-    case AF_INET6:
-      address->m_family = wxSOCKET_INET6;
-      break;
-#endif // wxUSE_IPV6
-    default:
-    {
-      address->m_error = wxSOCKET_INVOP;
-      return wxSOCKET_INVOP;
-    }
-  }
-
-  if (address->m_addr)
-    free(address->m_addr);
-
-  address->m_len  = len;
-  address->m_addr = (struct sockaddr *)malloc(len);
-
-  if (address->m_addr == NULL)
-  {
-    address->m_error = wxSOCKET_MEMERR;
-    return wxSOCKET_MEMERR;
-  }
-
-  memcpy(address->m_addr, addr, len);
-
-  return wxSOCKET_NOERROR;
-}
-
-wxSocketError _GAddress_translate_to(GAddress *address,
-                                    struct sockaddr **addr, int *len)
-{
-  if (!address->m_addr)
-  {
-    address->m_error = wxSOCKET_INVADDR;
-    return wxSOCKET_INVADDR;
-  }
-
-  *len = address->m_len;
-  *addr = (struct sockaddr *)malloc(address->m_len);
-  if (*addr == NULL)
-  {
-    address->m_error = wxSOCKET_MEMERR;
-    return wxSOCKET_MEMERR;
-  }
-
-  memcpy(*addr, address->m_addr, address->m_len);
-  return wxSOCKET_NOERROR;
-}
-
-/*
- * -------------------------------------------------------------------------
- * Internet address family
- * -------------------------------------------------------------------------
- */
-
-wxSocketError _GAddress_Init_INET(GAddress *address)
-{
-  address->m_len  = sizeof(struct sockaddr_in);
-  address->m_addr = (struct sockaddr *) malloc(address->m_len);
-  if (address->m_addr == NULL)
-  {
-    address->m_error = wxSOCKET_MEMERR;
-    return wxSOCKET_MEMERR;
-  }
-
-  address->m_family = wxSOCKET_INET;
-  address->m_realfamily = PF_INET;
-  ((struct sockaddr_in *)address->m_addr)->sin_family = AF_INET;
-  ((struct sockaddr_in *)address->m_addr)->sin_addr.s_addr = INADDR_ANY;
-
-  return wxSOCKET_NOERROR;
-}
-
-wxSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname)
-{
-  struct hostent *he;
-  struct in_addr *addr;
-
-  assert(address != NULL);
-
-  CHECK_ADDRESS(address, INET);
-
-  addr = &(((struct sockaddr_in *)address->m_addr)->sin_addr);
-
-  /* If it is a numeric host name, convert it now */
-#if defined(HAVE_INET_ATON)
-  if (inet_aton(hostname, addr) == 0)
-  {
-#elif defined(HAVE_INET_ADDR)
-  if ( (addr->s_addr = inet_addr(hostname)) == (unsigned)-1 )
-  {
-#else
-  /* Use gethostbyname by default */
-#ifndef __WXMAC__
-  int val = 1;  /* VA doesn't like constants in conditional expressions */
-  if (val)
-#endif
-  {
-#endif
-    struct in_addr *array_addr;
-
-    /* It is a real name, we solve it */
-    struct hostent h;
-#if defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
-    struct hostent_data buffer;
-#else
-    char buffer[1024];
-#endif
-    int err;
-    he = wxGethostbyname_r(hostname, &h, (void*)&buffer, sizeof(buffer), &err);
-    if (he == NULL)
-    {
-      /* Reset to invalid address */
-      addr->s_addr = INADDR_NONE;
-      address->m_error = wxSOCKET_NOHOST;
-      return wxSOCKET_NOHOST;
-    }
-
-    array_addr = (struct in_addr *) *(he->h_addr_list);
-    addr->s_addr = array_addr[0].s_addr;
-  }
-
-  return wxSOCKET_NOERROR;
-}
-
-
-wxSocketError GAddress_INET_SetBroadcastAddress(GAddress *address)
-{
-  return GAddress_INET_SetHostAddress(address, INADDR_BROADCAST);
-}
-
-wxSocketError GAddress_INET_SetAnyAddress(GAddress *address)
-{
-  return GAddress_INET_SetHostAddress(address, INADDR_ANY);
-}
-
-wxSocketError GAddress_INET_SetHostAddress(GAddress *address,
-                                          unsigned long hostaddr)
-{
-  struct in_addr *addr;
-
-  assert(address != NULL);
-
-  CHECK_ADDRESS(address, INET);
-
-  addr = &(((struct sockaddr_in *)address->m_addr)->sin_addr);
-  addr->s_addr = htonl(hostaddr);
-
-  return wxSOCKET_NOERROR;
-}
-
-wxSocketError GAddress_INET_SetPortName(GAddress *address, const char *port,
-                                       const char *protocol)
-{
-  struct servent *se;
-  struct sockaddr_in *addr;
-
-  assert(address != NULL);
-  CHECK_ADDRESS(address, INET);
-
-  if (!port)
-  {
-    address->m_error = wxSOCKET_INVPORT;
-    return wxSOCKET_INVPORT;
-  }
-
-#if defined(HAVE_FUNC_GETSERVBYNAME_R_4)
-    struct servent_data buffer;
-#else
-  char buffer[1024];
-#endif
-  struct servent serv;
-  se = wxGetservbyname_r(port, protocol, &serv,
-                        (void*)&buffer, sizeof(buffer));
-  if (!se)
-  {
-    /* the cast to int suppresses compiler warnings about subscript having the
-       type char */
-    if (isdigit((int)port[0]))
-    {
-      int port_int;
-
-      port_int = atoi(port);
-      addr = (struct sockaddr_in *)address->m_addr;
-      addr->sin_port = htons(port_int);
-      return wxSOCKET_NOERROR;
-    }
-
-    address->m_error = wxSOCKET_INVPORT;
-    return wxSOCKET_INVPORT;
-  }
-
-  addr = (struct sockaddr_in *)address->m_addr;
-  addr->sin_port = se->s_port;
-
-  return wxSOCKET_NOERROR;
-}
-
-wxSocketError GAddress_INET_SetPort(GAddress *address, unsigned short port)
-{
-  struct sockaddr_in *addr;
-
-  assert(address != NULL);
-  CHECK_ADDRESS(address, INET);
-
-  addr = (struct sockaddr_in *)address->m_addr;
-  addr->sin_port = htons(port);
-
-  return wxSOCKET_NOERROR;
-}
-
-wxSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, size_t sbuf)
-{
-  struct hostent *he;
-  char *addr_buf;
-  struct sockaddr_in *addr;
-
-  assert(address != NULL);
-  CHECK_ADDRESS(address, INET);
-
-  addr = (struct sockaddr_in *)address->m_addr;
-  addr_buf = (char *)&(addr->sin_addr);
-
-  struct hostent temphost;
-#if defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
-  struct hostent_data buffer;
-#else
-  char buffer[1024];
-#endif
-  int err;
-  he = wxGethostbyaddr_r(addr_buf, sizeof(addr->sin_addr), AF_INET, &temphost,
-                        (void*)&buffer, sizeof(buffer), &err);
-  if (he == NULL)
-  {
-    address->m_error = wxSOCKET_NOHOST;
-    return wxSOCKET_NOHOST;
-  }
-
-  strncpy(hostname, he->h_name, sbuf);
-
-  return wxSOCKET_NOERROR;
-}
-
-unsigned long GAddress_INET_GetHostAddress(GAddress *address)
-{
-  struct sockaddr_in *addr;
-
-  assert(address != NULL);
-  CHECK_ADDRESS_RETVAL(address, INET, 0);
-
-  addr = (struct sockaddr_in *)address->m_addr;
-
-  return ntohl(addr->sin_addr.s_addr);
-}
-
-unsigned short GAddress_INET_GetPort(GAddress *address)
-{
-  struct sockaddr_in *addr;
-
-  assert(address != NULL);
-  CHECK_ADDRESS_RETVAL(address, INET, 0);
-
-  addr = (struct sockaddr_in *)address->m_addr;
-  return ntohs(addr->sin_port);
-}
-
-#if wxUSE_IPV6
-/*
- * -------------------------------------------------------------------------
- * Internet IPv6 address family
- * -------------------------------------------------------------------------
- */
-
-wxSocketError _GAddress_Init_INET6(GAddress *address)
-{
-  struct in6_addr any_address = IN6ADDR_ANY_INIT;
-  address->m_len  = sizeof(struct sockaddr_in6);
-  address->m_addr = (struct sockaddr *) malloc(address->m_len);
-  if (address->m_addr == NULL)
-  {
-    address->m_error = wxSOCKET_MEMERR;
-    return wxSOCKET_MEMERR;
-  }
-  memset(address->m_addr,0,address->m_len);
-
-  address->m_family = wxSOCKET_INET6;
-  address->m_realfamily = AF_INET6;
-  ((struct sockaddr_in6 *)address->m_addr)->sin6_family = AF_INET6;
-  ((struct sockaddr_in6 *)address->m_addr)->sin6_addr = any_address;
-
-  return wxSOCKET_NOERROR;
-}
-
-wxSocketError GAddress_INET6_SetHostName(GAddress *address, const char *hostname)
-{
-  assert(address != NULL);
-  CHECK_ADDRESS(address, INET6);
-
-  addrinfo hints;
-  memset( & hints, 0, sizeof( hints ) );
-  hints.ai_family = AF_INET6;
-  addrinfo * info = 0;
-  if ( getaddrinfo( hostname, "0", & hints, & info ) || ! info )
-  {
-    address->m_error = wxSOCKET_NOHOST;
-    return wxSOCKET_NOHOST;
-  }
-
-  memcpy( address->m_addr, info->ai_addr, info->ai_addrlen );
-  freeaddrinfo( info );
-  return wxSOCKET_NOERROR;
-}
-
-wxSocketError GAddress_INET6_SetAnyAddress(GAddress *address)
-{
-  assert(address != NULL);
-
-  CHECK_ADDRESS(address, INET6);
-
-  struct in6_addr addr;
-  memset( & addr, 0, sizeof( addr ) );
-  return GAddress_INET6_SetHostAddress(address, addr);
-}
-wxSocketError GAddress_INET6_SetHostAddress(GAddress *address,
-                                          struct in6_addr hostaddr)
-{
-  assert(address != NULL);
-
-  CHECK_ADDRESS(address, INET6);
-
-  ((struct sockaddr_in6 *)address->m_addr)->sin6_addr = hostaddr;
-
-  return wxSOCKET_NOERROR;
-}
-
-wxSocketError GAddress_INET6_SetPortName(GAddress *address, const char *port,
-                                       const char *protocol)
-{
-  struct servent *se;
-  struct sockaddr_in6 *addr;
-
-  assert(address != NULL);
-  CHECK_ADDRESS(address, INET6);
-
-  if (!port)
-  {
-    address->m_error = wxSOCKET_INVPORT;
-    return wxSOCKET_INVPORT;
-  }
-
-  se = getservbyname(port, protocol);
-  if (!se)
-  {
-    if (isdigit(port[0]))
-    {
-      int port_int;
-
-      port_int = atoi(port);
-      addr = (struct sockaddr_in6 *)address->m_addr;
-      addr->sin6_port = htons((u_short) port_int);
-      return wxSOCKET_NOERROR;
-    }
-
-    address->m_error = wxSOCKET_INVPORT;
-    return wxSOCKET_INVPORT;
-  }
-
-  addr = (struct sockaddr_in6 *)address->m_addr;
-  addr->sin6_port = se->s_port;
-
-  return wxSOCKET_NOERROR;
-}
-
-wxSocketError GAddress_INET6_SetPort(GAddress *address, unsigned short port)
-{
-  struct sockaddr_in6 *addr;
-
-  assert(address != NULL);
-  CHECK_ADDRESS(address, INET6);
-
-  addr = (struct sockaddr_in6 *)address->m_addr;
-  addr->sin6_port = htons(port);
-
-  return wxSOCKET_NOERROR;
-}
-
-wxSocketError GAddress_INET6_GetHostName(GAddress *address, char *hostname, size_t sbuf)
-{
-  struct hostent *he;
-  char *addr_buf;
-  struct sockaddr_in6 *addr;
-
-  assert(address != NULL);
-  CHECK_ADDRESS(address, INET6);
-
-  addr = (struct sockaddr_in6 *)address->m_addr;
-  addr_buf = (char *)&(addr->sin6_addr);
-
-  he = gethostbyaddr(addr_buf, sizeof(addr->sin6_addr), AF_INET6);
-  if (he == NULL)
-  {
-    address->m_error = wxSOCKET_NOHOST;
-    return wxSOCKET_NOHOST;
-  }
-
-  strncpy(hostname, he->h_name, sbuf);
-
-  return wxSOCKET_NOERROR;
-}
-
-wxSocketError GAddress_INET6_GetHostAddress(GAddress *address,struct in6_addr *hostaddr)
-{
-  assert(address != NULL);
-  assert(hostaddr != NULL);
-  CHECK_ADDRESS_RETVAL(address, INET6, wxSOCKET_INVADDR);
-  *hostaddr = ( (struct sockaddr_in6 *)address->m_addr )->sin6_addr;
-  return wxSOCKET_NOERROR;
-}
-
-unsigned short GAddress_INET6_GetPort(GAddress *address)
-{
-  assert(address != NULL);
-  CHECK_ADDRESS_RETVAL(address, INET6, 0);
-
-  return ntohs( ((struct sockaddr_in6 *)address->m_addr)->sin6_port );
-}
-
-#endif // wxUSE_IPV6
-
-/*
- * -------------------------------------------------------------------------
- * Unix address family
- * -------------------------------------------------------------------------
- */
-
-#ifndef __VISAGECPP__
-wxSocketError _GAddress_Init_UNIX(GAddress *address)
-{
-  address->m_len  = sizeof(struct sockaddr_un);
-  address->m_addr = (struct sockaddr *)malloc(address->m_len);
-  if (address->m_addr == NULL)
-  {
-    address->m_error = wxSOCKET_MEMERR;
-    return wxSOCKET_MEMERR;
-  }
-
-  address->m_family = wxSOCKET_UNIX;
-  address->m_realfamily = PF_UNIX;
-  ((struct sockaddr_un *)address->m_addr)->sun_family = AF_UNIX;
-  ((struct sockaddr_un *)address->m_addr)->sun_path[0] = 0;
-
-  return wxSOCKET_NOERROR;
-}
-
-#define UNIX_SOCK_PATHLEN (sizeof(addr->sun_path)/sizeof(addr->sun_path[0]))
-
-wxSocketError GAddress_UNIX_SetPath(GAddress *address, const char *path)
-{
-  struct sockaddr_un *addr;
-
-  assert(address != NULL);
-
-  CHECK_ADDRESS(address, UNIX);
-
-  addr = ((struct sockaddr_un *)address->m_addr);
-  strncpy(addr->sun_path, path, UNIX_SOCK_PATHLEN);
-  addr->sun_path[UNIX_SOCK_PATHLEN - 1] = '\0';
-
-  return wxSOCKET_NOERROR;
-}
-
-wxSocketError GAddress_UNIX_GetPath(GAddress *address, char *path, size_t sbuf)
-{
-  struct sockaddr_un *addr;
-
-  assert(address != NULL);
-  CHECK_ADDRESS(address, UNIX);
-
-  addr = (struct sockaddr_un *)address->m_addr;
-
-  strncpy(path, addr->sun_path, sbuf);
-
-  return wxSOCKET_NOERROR;
-}
-#endif  /* !defined(__VISAGECPP__) */
-#endif  /* wxUSE_SOCKETS */
diff --git a/src/unix/sockunix.cpp b/src/unix/sockunix.cpp
new file mode 100644 (file)
index 0000000..0a0fbac
--- /dev/null
@@ -0,0 +1,1690 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        src/unix/sockunix.cpp
+// Purpose:     wxSocketImpl implementation for Unix systems
+// Authors:     Guilhem Lavaux, Guillermo Rodriguez Garcia, David Elliott,
+//              Vadim Zeitlin
+// Created:     April 1997
+// RCS-ID:      $Id$
+// Copyright:   (c) 1997 Guilhem Lavaux
+//              (c) 2008 Vadim Zeitlin
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+
+#include "wx/wxprec.h"
+
+#if wxUSE_SOCKETS
+
+#include "wx/private/fd.h"
+#include "wx/private/socket.h"
+#include "wx/unix/private/sockunix.h"
+#include "wx/private/gsocketiohandler.h"
+
+#if defined(__VISAGECPP__)
+#define BSD_SELECT /* use Berkeley Sockets select */
+#endif
+
+#if defined(__WATCOMC__)
+#include <errno.h>
+#include <nerrno.h>
+#endif
+
+#include <assert.h>
+#include <sys/types.h>
+#ifdef __VISAGECPP__
+#include <string.h>
+#include <sys/time.h>
+#include <types.h>
+#include <netinet/in.h>
+#endif
+#include <netdb.h>
+#include <sys/ioctl.h>
+
+#ifdef HAVE_SYS_SELECT_H
+#   include <sys/select.h>
+#endif
+
+#ifdef __VMS__
+#include <socket.h>
+struct sockaddr_un
+{
+    u_char  sun_len;        /* sockaddr len including null */
+    u_char  sun_family;     /* AF_UNIX */
+    char    sun_path[108];  /* path name (gag) */
+};
+#else
+#include <sys/socket.h>
+#include <sys/un.h>
+#endif
+
+#ifndef __VISAGECPP__
+#include <sys/time.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#else
+#include <nerrno.h>
+#  if __IBMCPP__ < 400
+#include <machine/endian.h>
+#include <socket.h>
+#include <ioctl.h>
+#include <select.h>
+#include <unistd.h>
+
+#define EBADF   SOCEBADF
+
+#    ifdef min
+#    undef min
+#    endif
+#  else
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
+
+#define close(a) soclose(a)
+#define select(a,b,c,d,e) bsdselect(a,b,c,d,e)
+int _System bsdselect(int,
+                      struct fd_set *,
+                      struct fd_set *,
+                      struct fd_set *,
+                      struct timeval *);
+int _System soclose(int);
+#  endif
+#endif
+#ifdef __EMX__
+#include <sys/select.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <ctype.h>
+#ifdef sun
+#  include <sys/filio.h>
+#endif
+#ifdef sgi
+#  include <bstring.h>
+#endif
+#ifdef _AIX
+#  include <strings.h>
+#endif
+#include <signal.h>
+
+#ifndef WX_SOCKLEN_T
+
+#ifdef VMS
+#  define WX_SOCKLEN_T unsigned int
+#else
+#  ifdef __GLIBC__
+#    if __GLIBC__ == 2
+#      define WX_SOCKLEN_T socklen_t
+#    endif
+#  elif defined(__WXMAC__)
+#    define WX_SOCKLEN_T socklen_t
+#  else
+#    define WX_SOCKLEN_T int
+#  endif
+#endif
+
+#endif /* SOCKLEN_T */
+
+#ifndef SOCKOPTLEN_T
+#define SOCKOPTLEN_T WX_SOCKLEN_T
+#endif
+
+/* UnixWare reportedly needs this for FIONBIO definition */
+#ifdef __UNIXWARE__
+#include <sys/filio.h>
+#endif
+
+/*
+ * INADDR_BROADCAST is identical to INADDR_NONE which is not defined
+ * on all systems. INADDR_BROADCAST should be fine to indicate an error.
+ */
+#ifndef INADDR_NONE
+#define INADDR_NONE INADDR_BROADCAST
+#endif
+
+#if defined(__VISAGECPP__) || defined(__WATCOMC__)
+
+    #define MASK_SIGNAL() {
+    #define UNMASK_SIGNAL() }
+
+#else
+    extern "C" { typedef void (*wxSigHandler)(int); }
+
+    #define MASK_SIGNAL()                       \
+    {                                           \
+        wxSigHandler old_handler = signal(SIGPIPE, SIG_IGN);
+
+    #define UNMASK_SIGNAL()                     \
+        signal(SIGPIPE, old_handler);           \
+    }
+
+#endif
+
+/* If a SIGPIPE is issued by a socket call on a remotely closed socket,
+   the program will "crash" unless it explicitly handles the SIGPIPE.
+   By using MSG_NOSIGNAL, the SIGPIPE is suppressed. Later, we will
+   use SO_NOSIGPIPE (if available), the BSD equivalent. */
+#ifdef MSG_NOSIGNAL
+#  define GSOCKET_MSG_NOSIGNAL MSG_NOSIGNAL
+#else /* MSG_NOSIGNAL not available (FreeBSD including OS X) */
+#  define GSOCKET_MSG_NOSIGNAL 0
+#endif /* MSG_NOSIGNAL */
+
+#if wxUSE_THREADS && (defined(HAVE_GETHOSTBYNAME) || defined(HAVE_GETSERVBYNAME))
+#  include "wx/thread.h"
+#endif
+
+#if defined(HAVE_GETHOSTBYNAME)
+static struct hostent * deepCopyHostent(struct hostent *h,
+                                       const struct hostent *he,
+                                       char *buffer, int size, int *err)
+{
+  /* copy old structure */
+  memcpy(h, he, sizeof(struct hostent));
+
+  /* copy name */
+  int len = strlen(h->h_name);
+  if (len > size)
+  {
+    *err = ENOMEM;
+    return NULL;
+  }
+  memcpy(buffer, h->h_name, len);
+  buffer[len] = '\0';
+  h->h_name = buffer;
+
+  /* track position in the buffer */
+  int pos = len + 1;
+
+  /* reuse len to store address length */
+  len = h->h_length;
+
+  /* ensure pointer alignment */
+  unsigned int misalign = sizeof(char *) - pos%sizeof(char *);
+  if(misalign < sizeof(char *))
+    pos += misalign;
+
+  /* leave space for pointer list */
+  char **p = h->h_addr_list, **q;
+  char **h_addr_list = (char **)(buffer + pos);
+  while(*(p++) != 0)
+    pos += sizeof(char *);
+
+  /* copy addresses and fill new pointer list */
+  for (p = h->h_addr_list, q = h_addr_list; *p != 0; p++, q++)
+  {
+    if (size < pos + len)
+    {
+      *err = ENOMEM;
+      return NULL;
+    }
+    memcpy(buffer + pos, *p, len); /* copy content */
+    *q = buffer + pos; /* set copied pointer to copied content */
+    pos += len;
+  }
+  *++q = 0; /* null terminate the pointer list */
+  h->h_addr_list = h_addr_list; /* copy pointer to pointers */
+
+  /* ensure word alignment of pointers */
+  misalign = sizeof(char *) - pos%sizeof(char *);
+  if(misalign < sizeof(char *))
+    pos += misalign;
+
+  /* leave space for pointer list */
+  p = h->h_aliases;
+  char **h_aliases = (char **)(buffer + pos);
+  while(*(p++) != 0)
+    pos += sizeof(char *);
+
+  /* copy aliases and fill new pointer list */
+  for (p = h->h_aliases, q = h_aliases; *p != 0; p++, q++)
+  {
+    len = strlen(*p);
+    if (size <= pos + len)
+    {
+      *err = ENOMEM;
+      return NULL;
+    }
+    memcpy(buffer + pos, *p, len); /* copy content */
+    buffer[pos + len] = '\0';
+    *q = buffer + pos; /* set copied pointer to copied content */
+    pos += len + 1;
+  }
+  *++q = 0; /* null terminate the pointer list */
+  h->h_aliases = h_aliases; /* copy pointer to pointers */
+
+  return h;
+}
+#endif
+
+#if defined(HAVE_GETHOSTBYNAME) && wxUSE_THREADS
+static wxMutex nameLock;
+#endif
+struct hostent * wxGethostbyname_r(const char *hostname, struct hostent *h,
+                                  void *buffer, int size, int *err)
+
+{
+  struct hostent *he = NULL;
+  *err = 0;
+#if defined(HAVE_FUNC_GETHOSTBYNAME_R_6)
+  if (gethostbyname_r(hostname, h, (char*)buffer, size, &he, err))
+    he = NULL;
+#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5)
+  he = gethostbyname_r(hostname, h, (char*)buffer, size, err);
+#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
+  if (gethostbyname_r(hostname, h, (struct hostent_data*) buffer))
+  {
+    he = NULL;
+    *err = h_errno;
+  }
+  else
+    he = h;
+#elif defined(HAVE_GETHOSTBYNAME)
+#if wxUSE_THREADS
+  wxMutexLocker locker(nameLock);
+#endif
+  he = gethostbyname(hostname);
+  if (!he)
+    *err = h_errno;
+  else
+    he = deepCopyHostent(h, he, (char*)buffer, size, err);
+#endif
+  return he;
+}
+
+#if defined(HAVE_GETHOSTBYNAME) && wxUSE_THREADS
+static wxMutex addrLock;
+#endif
+struct hostent * wxGethostbyaddr_r(const char *addr_buf, int buf_size,
+                                  int proto, struct hostent *h,
+                                  void *buffer, int size, int *err)
+{
+  struct hostent *he = NULL;
+  *err = 0;
+#if defined(HAVE_FUNC_GETHOSTBYNAME_R_6)
+  if (gethostbyaddr_r(addr_buf, buf_size, proto, h,
+                     (char*)buffer, size, &he, err))
+    he = NULL;
+#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5)
+  he = gethostbyaddr_r(addr_buf, buf_size, proto, h, (char*)buffer, size, err);
+#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
+  if (gethostbyaddr_r(addr_buf, buf_size, proto, h,
+                       (struct hostent_data*) buffer))
+  {
+    he = NULL;
+    *err = h_errno;
+  }
+  else
+    he = h;
+#elif defined(HAVE_GETHOSTBYNAME)
+#if wxUSE_THREADS
+  wxMutexLocker locker(addrLock);
+#endif
+  he = gethostbyaddr(addr_buf, buf_size, proto);
+  if (!he)
+    *err = h_errno;
+  else
+    he = deepCopyHostent(h, he, (char*)buffer, size, err);
+#endif
+  return he;
+}
+
+#if defined(HAVE_GETSERVBYNAME)
+static struct servent * deepCopyServent(struct servent *s,
+                                       const struct servent *se,
+                                       char *buffer, int size)
+{
+  /* copy plain old structure */
+  memcpy(s, se, sizeof(struct servent));
+
+  /* copy name */
+  int len = strlen(s->s_name);
+  if (len >= size)
+  {
+    return NULL;
+  }
+  memcpy(buffer, s->s_name, len);
+  buffer[len] = '\0';
+  s->s_name = buffer;
+
+  /* track position in the buffer */
+  int pos = len + 1;
+
+  /* copy protocol */
+  len = strlen(s->s_proto);
+  if (pos + len >= size)
+  {
+    return NULL;
+  }
+  memcpy(buffer + pos, s->s_proto, len);
+  buffer[pos + len] = '\0';
+  s->s_proto = buffer + pos;
+
+  /* track position in the buffer */
+  pos += len + 1;
+
+  /* ensure pointer alignment */
+  unsigned int misalign = sizeof(char *) - pos%sizeof(char *);
+  if(misalign < sizeof(char *))
+    pos += misalign;
+
+  /* leave space for pointer list */
+  char **p = s->s_aliases, **q;
+  char **s_aliases = (char **)(buffer + pos);
+  while(*(p++) != 0)
+    pos += sizeof(char *);
+
+  /* copy addresses and fill new pointer list */
+  for (p = s->s_aliases, q = s_aliases; *p != 0; p++, q++){
+    len = strlen(*p);
+    if (size <= pos + len)
+    {
+      return NULL;
+    }
+    memcpy(buffer + pos, *p, len); /* copy content */
+    buffer[pos + len] = '\0';
+    *q = buffer + pos; /* set copied pointer to copied content */
+    pos += len + 1;
+  }
+  *++q = 0; /* null terminate the pointer list */
+  s->s_aliases = s_aliases; /* copy pointer to pointers */
+  return s;
+}
+#endif
+
+#if defined(HAVE_GETSERVBYNAME) && wxUSE_THREADS
+static wxMutex servLock;
+#endif
+struct servent *wxGetservbyname_r(const char *port, const char *protocol,
+                                 struct servent *serv, void *buffer, int size)
+{
+  struct servent *se = NULL;
+#if defined(HAVE_FUNC_GETSERVBYNAME_R_6)
+  if (getservbyname_r(port, protocol, serv, (char*)buffer, size, &se))
+    se = NULL;
+#elif defined(HAVE_FUNC_GETSERVBYNAME_R_5)
+  se = getservbyname_r(port, protocol, serv, (char*)buffer, size);
+#elif defined(HAVE_FUNC_GETSERVBYNAME_R_4)
+  if (getservbyname_r(port, protocol, serv, (struct servent_data*) buffer))
+    se = NULL;
+  else
+    se = serv;
+#elif defined(HAVE_GETSERVBYNAME)
+#if wxUSE_THREADS
+  wxMutexLocker locker(servLock);
+#endif
+  se = getservbyname(port, protocol);
+  if (se)
+    se = deepCopyServent(serv, se, (char*)buffer, size);
+#endif
+  return se;
+}
+
+/* debugging helpers */
+#ifdef __GSOCKET_DEBUG__
+#  define SOCKET_DEBUG(args) printf args
+#else
+#  define SOCKET_DEBUG(args)
+#endif /* __GSOCKET_DEBUG__ */
+
+/* Constructors / Destructors for wxSocketImplUnix */
+
+wxSocketImplUnix::wxSocketImplUnix(wxSocketBase& wxsocket)
+    : wxSocketImpl(wxsocket)
+{
+    m_fds[0] =
+    m_fds[1] = -1;
+
+    m_use_events = false;
+}
+
+/*
+ *  Disallow further read/write operations on this socket, close
+ *  the fd and disable all callbacks.
+ */
+void wxSocketImplUnix::Shutdown()
+{
+    /* Don't allow events to fire after socket has been closed */
+    DisableEvents();
+
+    wxSocketImpl::Shutdown();
+}
+
+/*
+ *  Waits for an incoming client connection. Returns a pointer to
+ *  a wxSocketImplUnix object, or NULL if there was an error, in which case
+ *  the last error field will be updated for the calling wxSocketImplUnix.
+ *
+ *  Error codes (set in the calling wxSocketImplUnix)
+ *    wxSOCKET_INVSOCK    - the socket is not valid or not a server.
+ *    wxSOCKET_TIMEDOUT   - timeout, no incoming connections.
+ *    wxSOCKET_WOULDBLOCK - the call would block and the socket is nonblocking.
+ *    wxSOCKET_MEMERR     - couldn't allocate memory.
+ *    wxSOCKET_IOERR      - low-level error.
+ */
+wxSocketImpl *wxSocketImplUnix::WaitConnection(wxSocketBase& wxsocket)
+{
+  wxSockAddr from;
+  WX_SOCKLEN_T fromlen = sizeof(from);
+  wxSocketImpl *connection;
+  wxSocketError err;
+  int arg = 1;
+
+  /* If the socket has already been created, we exit immediately */
+  if (m_fd == INVALID_SOCKET || !m_server)
+  {
+    m_error = wxSOCKET_INVSOCK;
+    return NULL;
+  }
+
+  /* Create a wxSocketImplUnix object for the new connection */
+  connection = wxSocketImplUnix::Create(wxsocket);
+
+  if (!connection)
+  {
+    m_error = wxSOCKET_MEMERR;
+    return NULL;
+  }
+
+  /* Wait for a connection (with timeout) */
+  if (Input_Timeout() == wxSOCKET_TIMEDOUT)
+  {
+    delete connection;
+    /* m_error set by Input_Timeout */
+    return NULL;
+  }
+
+  connection->m_fd = accept(m_fd, (sockaddr*)&from, (WX_SOCKLEN_T *) &fromlen);
+
+  /* Reenable CONNECTION events */
+  EnableEvent(wxSOCKET_CONNECTION);
+
+  if (connection->m_fd == INVALID_SOCKET)
+  {
+    if (errno == EWOULDBLOCK)
+      m_error = wxSOCKET_WOULDBLOCK;
+    else
+      m_error = wxSOCKET_IOERR;
+
+    delete connection;
+    return NULL;
+  }
+
+  /* Initialize all fields */
+  connection->m_server   = false;
+  connection->m_stream   = true;
+
+  /* Setup the peer address field */
+  connection->m_peer = GAddress_new();
+  if (!connection->m_peer)
+  {
+    delete connection;
+    m_error = wxSOCKET_MEMERR;
+    return NULL;
+  }
+
+  err = _GAddress_translate_from(connection->m_peer, (sockaddr*)&from, fromlen);
+  if (err != wxSOCKET_NOERROR)
+  {
+    delete connection;
+    m_error = err;
+    return NULL;
+  }
+
+#if defined(__EMX__) || defined(__VISAGECPP__)
+  ioctl(connection->m_fd, FIONBIO, (char*)&arg, sizeof(arg));
+#else
+  ioctl(connection->m_fd, FIONBIO, &arg);
+#endif
+  if (m_use_events)
+    connection->Notify(true);
+
+  return connection;
+}
+
+void wxSocketImplUnix::Notify(bool flag)
+{
+    if (flag == m_use_events)
+        return;
+    m_use_events = flag;
+    DoEnableEvents(flag);
+}
+
+void wxSocketImplUnix::DoEnableEvents(bool flag)
+{
+    wxSocketManager * const manager = wxSocketManager::Get();
+    if ( flag )
+    {
+        manager->Install_Callback(this, wxSOCKET_INPUT);
+        manager->Install_Callback(this, wxSOCKET_OUTPUT);
+    }
+    else // off
+    {
+        manager->Uninstall_Callback(this, wxSOCKET_INPUT);
+        manager->Uninstall_Callback(this, wxSOCKET_OUTPUT);
+    }
+}
+
+wxSocketError wxSocketImplUnix::DoHandleConnect(int ret)
+{
+  /* We only call EnableEvents() if we know we aren't shutting down the socket.
+   * NB: EnableEvents() needs to be called whether the socket is blocking or
+   * non-blocking, it just shouldn't be called prior to knowing there is a
+   * connection _if_ blocking sockets are being used.
+   * If connect above returns 0, we are already connected and need to make the
+   * call to EnableEvents() now.
+   */
+  if ( m_non_blocking || (ret == 0) )
+    EnableEvents();
+
+  if (ret == -1)
+  {
+    const int err = errno;
+
+    /* If connect failed with EINPROGRESS and the wxSocketImplUnix object
+     * is in blocking mode, we select() for the specified timeout
+     * checking for writability to see if the connection request
+     * completes.
+     */
+    if ((err == EINPROGRESS) && (!m_non_blocking))
+    {
+      if (Output_Timeout() == wxSOCKET_TIMEDOUT)
+      {
+        Close();
+        /* m_error is set in Output_Timeout */
+        return wxSOCKET_TIMEDOUT;
+      }
+      else
+      {
+        int error;
+        SOCKOPTLEN_T len = sizeof(error);
+
+        getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (char*) &error, &len);
+        EnableEvents();
+
+        if (!error)
+          return wxSOCKET_NOERROR;
+      }
+    }
+
+    /* If connect failed with EINPROGRESS and the wxSocketImplUnix object
+     * is set to nonblocking, we set m_error to wxSOCKET_WOULDBLOCK
+     * (and return wxSOCKET_WOULDBLOCK) but we don't close the socket;
+     * this way if the connection completes, a wxSOCKET_CONNECTION
+     * event will be generated, if enabled.
+     */
+    if ((err == EINPROGRESS) && (m_non_blocking))
+    {
+      m_establishing = true;
+      m_error = wxSOCKET_WOULDBLOCK;
+      return wxSOCKET_WOULDBLOCK;
+    }
+
+    /* If connect failed with an error other than EINPROGRESS,
+     * then the call to Connect has failed.
+     */
+    Close();
+    m_error = wxSOCKET_IOERR;
+
+    return wxSOCKET_IOERR;
+  }
+
+  return wxSOCKET_NOERROR;
+}
+
+/* Generic IO */
+
+/* Like recv(), send(), ... */
+int wxSocketImplUnix::Read(char *buffer, int size)
+{
+  int ret;
+
+  if (m_fd == INVALID_SOCKET || m_server)
+  {
+    m_error = wxSOCKET_INVSOCK;
+    return -1;
+  }
+
+  /* Disable events during query of socket status */
+  DisableEvent(wxSOCKET_INPUT);
+
+  /* If the socket is blocking, wait for data (with a timeout) */
+  if (Input_Timeout() == wxSOCKET_TIMEDOUT) {
+    m_error = wxSOCKET_TIMEDOUT;
+    /* Don't return here immediately, otherwise socket events would not be
+     * re-enabled! */
+    ret = -1;
+  }
+  else
+  {
+    /* Read the data */
+    if (m_stream)
+      ret = Recv_Stream(buffer, size);
+    else
+      ret = Recv_Dgram(buffer, size);
+
+    /*
+     * If recv returned zero for a TCP socket (if m_stream == NULL, it's an UDP
+     * socket and empty datagrams are possible), then the connection has been
+     * gracefully closed.
+     *
+     * Otherwise, recv has returned an error (-1), in which case we have lost
+     * the socket only if errno does _not_ indicate that there may be more data
+     * to read.
+     */
+    if ((ret == 0) && m_stream)
+    {
+      /* Make sure wxSOCKET_LOST event gets sent and shut down the socket */
+      if (m_use_events)
+      {
+        m_detected = wxSOCKET_LOST_FLAG;
+        Detected_Read();
+        return 0;
+      }
+    }
+    else if (ret == -1)
+    {
+      if ((errno == EWOULDBLOCK) || (errno == EAGAIN))
+        m_error = wxSOCKET_WOULDBLOCK;
+      else
+        m_error = wxSOCKET_IOERR;
+    }
+  }
+
+  /* Enable events again now that we are done processing */
+  EnableEvent(wxSOCKET_INPUT);
+
+  return ret;
+}
+
+int wxSocketImplUnix::Write(const char *buffer, int size)
+{
+  int ret;
+
+  SOCKET_DEBUG(( "Write #1, size %d\n", size ));
+
+  if (m_fd == INVALID_SOCKET || m_server)
+  {
+    m_error = wxSOCKET_INVSOCK;
+    return -1;
+  }
+
+  SOCKET_DEBUG(( "Write #2, size %d\n", size ));
+
+  /* If the socket is blocking, wait for writability (with a timeout) */
+  if (Output_Timeout() == wxSOCKET_TIMEDOUT)
+    return -1;
+
+  SOCKET_DEBUG(( "Write #3, size %d\n", size ));
+
+  /* Write the data */
+  if (m_stream)
+    ret = Send_Stream(buffer, size);
+  else
+    ret = Send_Dgram(buffer, size);
+
+  SOCKET_DEBUG(( "Write #4, size %d\n", size ));
+
+  if (ret == -1)
+  {
+    if ((errno == EWOULDBLOCK) || (errno == EAGAIN))
+    {
+      m_error = wxSOCKET_WOULDBLOCK;
+      SOCKET_DEBUG(( "Write error WOULDBLOCK\n" ));
+    }
+    else
+    {
+      m_error = wxSOCKET_IOERR;
+      SOCKET_DEBUG(( "Write error IOERR\n" ));
+    }
+
+    /* Only reenable OUTPUT events after an error (just like WSAAsyncSelect
+     * in MSW). Once the first OUTPUT event is received, users can assume
+     * that the socket is writable until a read operation fails. Only then
+     * will further OUTPUT events be posted.
+     */
+    EnableEvent(wxSOCKET_OUTPUT);
+
+    return -1;
+  }
+
+  SOCKET_DEBUG(( "Write #5, size %d ret %d\n", size, ret ));
+
+  return ret;
+}
+
+/* Flags */
+
+void wxSocketImplUnix::EnableEvent(wxSocketNotify event)
+{
+    if (m_use_events)
+    {
+        m_detected &= ~(1 << event);
+        wxSocketManager::Get()->Install_Callback(this, event);
+    }
+}
+
+void wxSocketImplUnix::DisableEvent(wxSocketNotify event)
+{
+    if (m_use_events)
+    {
+        m_detected |= (1 << event);
+        wxSocketManager::Get()->Uninstall_Callback(this, event);
+    }
+}
+
+/*
+ *  For blocking sockets, wait until data is available or
+ *  until timeout ellapses.
+ */
+wxSocketError wxSocketImplUnix::Input_Timeout()
+{
+  fd_set readfds;
+  int ret;
+
+  // Linux select() will overwrite the struct on return so make a copy
+  struct timeval tv = m_timeout;
+
+  if (!m_non_blocking)
+  {
+    wxFD_ZERO(&readfds);
+    wxFD_SET(m_fd, &readfds);
+    ret = select(m_fd + 1, &readfds, NULL, NULL, &tv);
+    if (ret == 0)
+    {
+      SOCKET_DEBUG(( "Input_Timeout, select returned 0\n" ));
+      m_error = wxSOCKET_TIMEDOUT;
+      return wxSOCKET_TIMEDOUT;
+    }
+
+    if (ret == -1)
+    {
+      SOCKET_DEBUG(( "Input_Timeout, select returned -1\n" ));
+      if (errno == EBADF) { SOCKET_DEBUG(( "Invalid file descriptor\n" )); }
+      if (errno == EINTR) { SOCKET_DEBUG(( "A non blocked signal was caught\n" )); }
+      if (errno == EINVAL) { SOCKET_DEBUG(( "The highest number descriptor is negative\n" )); }
+      if (errno == ENOMEM) { SOCKET_DEBUG(( "Not enough memory\n" )); }
+      m_error = wxSOCKET_TIMEDOUT;
+      return wxSOCKET_TIMEDOUT;
+    }
+  }
+
+  return wxSOCKET_NOERROR;
+}
+
+/*
+ *  For blocking sockets, wait until data can be sent without
+ *  blocking or until timeout ellapses.
+ */
+wxSocketError wxSocketImplUnix::Output_Timeout()
+{
+  fd_set writefds;
+  int ret;
+
+  // Linux select() will overwrite the struct on return so make a copy
+  struct timeval tv = m_timeout;
+
+  SOCKET_DEBUG( ("m_non_blocking has: %d\n", (int)m_non_blocking) );
+
+  if (!m_non_blocking)
+  {
+    wxFD_ZERO(&writefds);
+    wxFD_SET(m_fd, &writefds);
+    ret = select(m_fd + 1, NULL, &writefds, NULL, &tv);
+    if (ret == 0)
+    {
+      SOCKET_DEBUG(( "Output_Timeout, select returned 0\n" ));
+      m_error = wxSOCKET_TIMEDOUT;
+      return wxSOCKET_TIMEDOUT;
+    }
+
+    if (ret == -1)
+    {
+      SOCKET_DEBUG(( "Output_Timeout, select returned -1\n" ));
+      if (errno == EBADF) { SOCKET_DEBUG(( "Invalid file descriptor\n" )); }
+      if (errno == EINTR) { SOCKET_DEBUG(( "A non blocked signal was caught\n" )); }
+      if (errno == EINVAL) { SOCKET_DEBUG(( "The highest number descriptor is negative\n" )); }
+      if (errno == ENOMEM) { SOCKET_DEBUG(( "Not enough memory\n" )); }
+      m_error = wxSOCKET_TIMEDOUT;
+      return wxSOCKET_TIMEDOUT;
+    }
+
+    if ( ! wxFD_ISSET(m_fd, &writefds) )
+    {
+        SOCKET_DEBUG(( "Output_Timeout is buggy!\n" ));
+    }
+    else
+    {
+        SOCKET_DEBUG(( "Output_Timeout seems correct\n" ));
+    }
+  }
+  else
+  {
+    SOCKET_DEBUG(( "Output_Timeout, didn't try select!\n" ));
+  }
+
+  return wxSOCKET_NOERROR;
+}
+
+int wxSocketImplUnix::Recv_Stream(char *buffer, int size)
+{
+  int ret;
+  do
+  {
+    ret = recv(m_fd, buffer, size, GSOCKET_MSG_NOSIGNAL);
+  }
+  while (ret == -1 && errno == EINTR); /* Loop until not interrupted */
+
+  return ret;
+}
+
+int wxSocketImplUnix::Recv_Dgram(char *buffer, int size)
+{
+  wxSockAddr from;
+  WX_SOCKLEN_T fromlen = sizeof(from);
+  int ret;
+  wxSocketError err;
+
+  fromlen = sizeof(from);
+
+  do
+  {
+    ret = recvfrom(m_fd, buffer, size, 0, (sockaddr*)&from, (WX_SOCKLEN_T *) &fromlen);
+  }
+  while (ret == -1 && errno == EINTR); /* Loop until not interrupted */
+
+  if (ret == -1)
+    return -1;
+
+  /* Translate a system address into a wxSocketImplUnix address */
+  if (!m_peer)
+  {
+    m_peer = GAddress_new();
+    if (!m_peer)
+    {
+      m_error = wxSOCKET_MEMERR;
+      return -1;
+    }
+  }
+
+  err = _GAddress_translate_from(m_peer, (sockaddr*)&from, fromlen);
+  if (err != wxSOCKET_NOERROR)
+  {
+    GAddress_destroy(m_peer);
+    m_peer  = NULL;
+    m_error = err;
+    return -1;
+  }
+
+  return ret;
+}
+
+int wxSocketImplUnix::Send_Stream(const char *buffer, int size)
+{
+  int ret;
+
+  MASK_SIGNAL();
+
+  do
+  {
+    ret = send(m_fd, (char *)buffer, size, GSOCKET_MSG_NOSIGNAL);
+  }
+  while (ret == -1 && errno == EINTR); /* Loop until not interrupted */
+
+  UNMASK_SIGNAL();
+
+  return ret;
+}
+
+int wxSocketImplUnix::Send_Dgram(const char *buffer, int size)
+{
+  struct sockaddr *addr;
+  int len, ret;
+  wxSocketError err;
+
+  if (!m_peer)
+  {
+    m_error = wxSOCKET_INVADDR;
+    return -1;
+  }
+
+  err = _GAddress_translate_to(m_peer, &addr, &len);
+  if (err != wxSOCKET_NOERROR)
+  {
+    m_error = err;
+    return -1;
+  }
+
+  MASK_SIGNAL();
+
+  do
+  {
+    ret = sendto(m_fd, (char *)buffer, size, 0, addr, len);
+  }
+  while (ret == -1 && errno == EINTR); /* Loop until not interrupted */
+
+  UNMASK_SIGNAL();
+
+  /* Frees memory allocated from _GAddress_translate_to */
+  free(addr);
+
+  return ret;
+}
+
+void wxSocketImplUnix::OnStateChange(wxSocketNotify event)
+{
+    DisableEvent(event);
+    NotifyOnStateChange(event);
+
+    if ( event == wxSOCKET_LOST )
+        Shutdown();
+}
+
+void wxSocketImplUnix::Detected_Read()
+{
+  char c;
+
+  /* Safeguard against straggling call to Detected_Read */
+  if (m_fd == INVALID_SOCKET)
+  {
+    return;
+  }
+
+  /* If we have already detected a LOST event, then don't try
+   * to do any further processing.
+   */
+  if ((m_detected & wxSOCKET_LOST_FLAG) != 0)
+  {
+    m_establishing = false;
+
+    OnStateChange(wxSOCKET_LOST);
+    return;
+  }
+
+  int num =  recv(m_fd, &c, 1, MSG_PEEK | GSOCKET_MSG_NOSIGNAL);
+
+  if (num > 0)
+  {
+    OnStateChange(wxSOCKET_INPUT);
+  }
+  else
+  {
+    if (m_server && m_stream)
+    {
+      OnStateChange(wxSOCKET_CONNECTION);
+    }
+    else if (num == 0)
+    {
+      if (m_stream)
+      {
+        /* graceful shutdown */
+        OnStateChange(wxSOCKET_LOST);
+      }
+      else
+      {
+        /* Empty datagram received */
+        OnStateChange(wxSOCKET_INPUT);
+      }
+    }
+    else
+    {
+      /* Do not throw a lost event in cases where the socket isn't really lost */
+      if ((errno == EWOULDBLOCK) || (errno == EAGAIN) || (errno == EINTR))
+      {
+        OnStateChange(wxSOCKET_INPUT);
+      }
+      else
+      {
+        OnStateChange(wxSOCKET_LOST);
+      }
+    }
+  }
+}
+
+void wxSocketImplUnix::Detected_Write()
+{
+  /* If we have already detected a LOST event, then don't try
+   * to do any further processing.
+   */
+  if ((m_detected & wxSOCKET_LOST_FLAG) != 0)
+  {
+    m_establishing = false;
+
+    OnStateChange(wxSOCKET_LOST);
+    return;
+  }
+
+  if (m_establishing && !m_server)
+  {
+    int error;
+    SOCKOPTLEN_T len = sizeof(error);
+
+    m_establishing = false;
+
+    getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (char*)&error, &len);
+
+    if (error)
+    {
+      OnStateChange(wxSOCKET_LOST);
+    }
+    else
+    {
+      OnStateChange(wxSOCKET_CONNECTION);
+      /* We have to fire this event by hand because CONNECTION (for clients)
+       * and OUTPUT are internally the same and we just disabled CONNECTION
+       * events with the above macro.
+       */
+      OnStateChange(wxSOCKET_OUTPUT);
+    }
+  }
+  else
+  {
+    OnStateChange(wxSOCKET_OUTPUT);
+  }
+}
+
+/*
+ * -------------------------------------------------------------------------
+ * GAddress
+ * -------------------------------------------------------------------------
+ */
+
+/* CHECK_ADDRESS verifies that the current address family is either
+ * wxSOCKET_NOFAMILY or wxSOCKET_*family*, and if it is wxSOCKET_NOFAMILY, it
+ * initalizes it to be a wxSOCKET_*family*. In other cases, it returns
+ * an appropiate error code.
+ *
+ * CHECK_ADDRESS_RETVAL does the same but returning 'retval' on error.
+ */
+#define CHECK_ADDRESS(address, family)                              \
+{                                                                   \
+  if (address->m_family == wxSOCKET_NOFAMILY)                          \
+    if (_GAddress_Init_##family(address) != wxSOCKET_NOERROR)          \
+      return address->m_error;                                      \
+  if (address->m_family != wxSOCKET_##family)                          \
+  {                                                                 \
+    address->m_error = wxSOCKET_INVADDR;                               \
+    return wxSOCKET_INVADDR;                                           \
+  }                                                                 \
+}
+
+#define CHECK_ADDRESS_RETVAL(address, family, retval)               \
+{                                                                   \
+  if (address->m_family == wxSOCKET_NOFAMILY)                          \
+    if (_GAddress_Init_##family(address) != wxSOCKET_NOERROR)          \
+      return retval;                                                \
+  if (address->m_family != wxSOCKET_##family)                          \
+  {                                                                 \
+    address->m_error = wxSOCKET_INVADDR;                               \
+    return retval;                                                  \
+  }                                                                 \
+}
+
+
+GAddress *GAddress_new(void)
+{
+  GAddress *address;
+
+  if ((address = (GAddress *) malloc(sizeof(GAddress))) == NULL)
+    return NULL;
+
+  address->m_family  = wxSOCKET_NOFAMILY;
+  address->m_addr    = NULL;
+  address->m_len     = 0;
+
+  return address;
+}
+
+GAddress *GAddress_copy(GAddress *address)
+{
+  GAddress *addr2;
+
+  assert(address != NULL);
+
+  if ((addr2 = (GAddress *) malloc(sizeof(GAddress))) == NULL)
+    return NULL;
+
+  memcpy(addr2, address, sizeof(GAddress));
+
+  if (address->m_addr && address->m_len > 0)
+  {
+    addr2->m_addr = (struct sockaddr *)malloc(addr2->m_len);
+    if (addr2->m_addr == NULL)
+    {
+      free(addr2);
+      return NULL;
+    }
+    memcpy(addr2->m_addr, address->m_addr, addr2->m_len);
+  }
+
+  return addr2;
+}
+
+void GAddress_destroy(GAddress *address)
+{
+  assert(address != NULL);
+
+  if (address->m_addr)
+    free(address->m_addr);
+
+  free(address);
+}
+
+void GAddress_SetFamily(GAddress *address, GAddressType type)
+{
+  assert(address != NULL);
+
+  address->m_family = type;
+}
+
+GAddressType GAddress_GetFamily(GAddress *address)
+{
+  assert(address != NULL);
+
+  return address->m_family;
+}
+
+wxSocketError _GAddress_translate_from(GAddress *address,
+                                      struct sockaddr *addr, int len)
+{
+  address->m_realfamily = addr->sa_family;
+  switch (addr->sa_family)
+  {
+    case AF_INET:
+      address->m_family = wxSOCKET_INET;
+      break;
+    case AF_UNIX:
+      address->m_family = wxSOCKET_UNIX;
+      break;
+#if wxUSE_IPV6
+    case AF_INET6:
+      address->m_family = wxSOCKET_INET6;
+      break;
+#endif // wxUSE_IPV6
+    default:
+    {
+      address->m_error = wxSOCKET_INVOP;
+      return wxSOCKET_INVOP;
+    }
+  }
+
+  if (address->m_addr)
+    free(address->m_addr);
+
+  address->m_len  = len;
+  address->m_addr = (struct sockaddr *)malloc(len);
+
+  if (address->m_addr == NULL)
+  {
+    address->m_error = wxSOCKET_MEMERR;
+    return wxSOCKET_MEMERR;
+  }
+
+  memcpy(address->m_addr, addr, len);
+
+  return wxSOCKET_NOERROR;
+}
+
+wxSocketError _GAddress_translate_to(GAddress *address,
+                                    struct sockaddr **addr, int *len)
+{
+  if (!address->m_addr)
+  {
+    address->m_error = wxSOCKET_INVADDR;
+    return wxSOCKET_INVADDR;
+  }
+
+  *len = address->m_len;
+  *addr = (struct sockaddr *)malloc(address->m_len);
+  if (*addr == NULL)
+  {
+    address->m_error = wxSOCKET_MEMERR;
+    return wxSOCKET_MEMERR;
+  }
+
+  memcpy(*addr, address->m_addr, address->m_len);
+  return wxSOCKET_NOERROR;
+}
+
+/*
+ * -------------------------------------------------------------------------
+ * Internet address family
+ * -------------------------------------------------------------------------
+ */
+
+wxSocketError _GAddress_Init_INET(GAddress *address)
+{
+  address->m_len  = sizeof(struct sockaddr_in);
+  address->m_addr = (struct sockaddr *) malloc(address->m_len);
+  if (address->m_addr == NULL)
+  {
+    address->m_error = wxSOCKET_MEMERR;
+    return wxSOCKET_MEMERR;
+  }
+
+  address->m_family = wxSOCKET_INET;
+  address->m_realfamily = PF_INET;
+  ((struct sockaddr_in *)address->m_addr)->sin_family = AF_INET;
+  ((struct sockaddr_in *)address->m_addr)->sin_addr.s_addr = INADDR_ANY;
+
+  return wxSOCKET_NOERROR;
+}
+
+wxSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname)
+{
+  struct hostent *he;
+  struct in_addr *addr;
+
+  assert(address != NULL);
+
+  CHECK_ADDRESS(address, INET);
+
+  addr = &(((struct sockaddr_in *)address->m_addr)->sin_addr);
+
+  /* If it is a numeric host name, convert it now */
+#if defined(HAVE_INET_ATON)
+  if (inet_aton(hostname, addr) == 0)
+  {
+#elif defined(HAVE_INET_ADDR)
+  if ( (addr->s_addr = inet_addr(hostname)) == (unsigned)-1 )
+  {
+#else
+  /* Use gethostbyname by default */
+#ifndef __WXMAC__
+  int val = 1;  /* VA doesn't like constants in conditional expressions */
+  if (val)
+#endif
+  {
+#endif
+    struct in_addr *array_addr;
+
+    /* It is a real name, we solve it */
+    struct hostent h;
+#if defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
+    struct hostent_data buffer;
+#else
+    char buffer[1024];
+#endif
+    int err;
+    he = wxGethostbyname_r(hostname, &h, (void*)&buffer, sizeof(buffer), &err);
+    if (he == NULL)
+    {
+      /* Reset to invalid address */
+      addr->s_addr = INADDR_NONE;
+      address->m_error = wxSOCKET_NOHOST;
+      return wxSOCKET_NOHOST;
+    }
+
+    array_addr = (struct in_addr *) *(he->h_addr_list);
+    addr->s_addr = array_addr[0].s_addr;
+  }
+
+  return wxSOCKET_NOERROR;
+}
+
+
+wxSocketError GAddress_INET_SetBroadcastAddress(GAddress *address)
+{
+  return GAddress_INET_SetHostAddress(address, INADDR_BROADCAST);
+}
+
+wxSocketError GAddress_INET_SetAnyAddress(GAddress *address)
+{
+  return GAddress_INET_SetHostAddress(address, INADDR_ANY);
+}
+
+wxSocketError GAddress_INET_SetHostAddress(GAddress *address,
+                                          unsigned long hostaddr)
+{
+  struct in_addr *addr;
+
+  assert(address != NULL);
+
+  CHECK_ADDRESS(address, INET);
+
+  addr = &(((struct sockaddr_in *)address->m_addr)->sin_addr);
+  addr->s_addr = htonl(hostaddr);
+
+  return wxSOCKET_NOERROR;
+}
+
+wxSocketError GAddress_INET_SetPortName(GAddress *address, const char *port,
+                                       const char *protocol)
+{
+  struct servent *se;
+  struct sockaddr_in *addr;
+
+  assert(address != NULL);
+  CHECK_ADDRESS(address, INET);
+
+  if (!port)
+  {
+    address->m_error = wxSOCKET_INVPORT;
+    return wxSOCKET_INVPORT;
+  }
+
+#if defined(HAVE_FUNC_GETSERVBYNAME_R_4)
+    struct servent_data buffer;
+#else
+  char buffer[1024];
+#endif
+  struct servent serv;
+  se = wxGetservbyname_r(port, protocol, &serv,
+                        (void*)&buffer, sizeof(buffer));
+  if (!se)
+  {
+    /* the cast to int suppresses compiler warnings about subscript having the
+       type char */
+    if (isdigit((int)port[0]))
+    {
+      int port_int;
+
+      port_int = atoi(port);
+      addr = (struct sockaddr_in *)address->m_addr;
+      addr->sin_port = htons(port_int);
+      return wxSOCKET_NOERROR;
+    }
+
+    address->m_error = wxSOCKET_INVPORT;
+    return wxSOCKET_INVPORT;
+  }
+
+  addr = (struct sockaddr_in *)address->m_addr;
+  addr->sin_port = se->s_port;
+
+  return wxSOCKET_NOERROR;
+}
+
+wxSocketError GAddress_INET_SetPort(GAddress *address, unsigned short port)
+{
+  struct sockaddr_in *addr;
+
+  assert(address != NULL);
+  CHECK_ADDRESS(address, INET);
+
+  addr = (struct sockaddr_in *)address->m_addr;
+  addr->sin_port = htons(port);
+
+  return wxSOCKET_NOERROR;
+}
+
+wxSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, size_t sbuf)
+{
+  struct hostent *he;
+  char *addr_buf;
+  struct sockaddr_in *addr;
+
+  assert(address != NULL);
+  CHECK_ADDRESS(address, INET);
+
+  addr = (struct sockaddr_in *)address->m_addr;
+  addr_buf = (char *)&(addr->sin_addr);
+
+  struct hostent temphost;
+#if defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
+  struct hostent_data buffer;
+#else
+  char buffer[1024];
+#endif
+  int err;
+  he = wxGethostbyaddr_r(addr_buf, sizeof(addr->sin_addr), AF_INET, &temphost,
+                        (void*)&buffer, sizeof(buffer), &err);
+  if (he == NULL)
+  {
+    address->m_error = wxSOCKET_NOHOST;
+    return wxSOCKET_NOHOST;
+  }
+
+  strncpy(hostname, he->h_name, sbuf);
+
+  return wxSOCKET_NOERROR;
+}
+
+unsigned long GAddress_INET_GetHostAddress(GAddress *address)
+{
+  struct sockaddr_in *addr;
+
+  assert(address != NULL);
+  CHECK_ADDRESS_RETVAL(address, INET, 0);
+
+  addr = (struct sockaddr_in *)address->m_addr;
+
+  return ntohl(addr->sin_addr.s_addr);
+}
+
+unsigned short GAddress_INET_GetPort(GAddress *address)
+{
+  struct sockaddr_in *addr;
+
+  assert(address != NULL);
+  CHECK_ADDRESS_RETVAL(address, INET, 0);
+
+  addr = (struct sockaddr_in *)address->m_addr;
+  return ntohs(addr->sin_port);
+}
+
+#if wxUSE_IPV6
+/*
+ * -------------------------------------------------------------------------
+ * Internet IPv6 address family
+ * -------------------------------------------------------------------------
+ */
+
+wxSocketError _GAddress_Init_INET6(GAddress *address)
+{
+  struct in6_addr any_address = IN6ADDR_ANY_INIT;
+  address->m_len  = sizeof(struct sockaddr_in6);
+  address->m_addr = (struct sockaddr *) malloc(address->m_len);
+  if (address->m_addr == NULL)
+  {
+    address->m_error = wxSOCKET_MEMERR;
+    return wxSOCKET_MEMERR;
+  }
+  memset(address->m_addr,0,address->m_len);
+
+  address->m_family = wxSOCKET_INET6;
+  address->m_realfamily = AF_INET6;
+  ((struct sockaddr_in6 *)address->m_addr)->sin6_family = AF_INET6;
+  ((struct sockaddr_in6 *)address->m_addr)->sin6_addr = any_address;
+
+  return wxSOCKET_NOERROR;
+}
+
+wxSocketError GAddress_INET6_SetHostName(GAddress *address, const char *hostname)
+{
+  assert(address != NULL);
+  CHECK_ADDRESS(address, INET6);
+
+  addrinfo hints;
+  memset( & hints, 0, sizeof( hints ) );
+  hints.ai_family = AF_INET6;
+  addrinfo * info = 0;
+  if ( getaddrinfo( hostname, "0", & hints, & info ) || ! info )
+  {
+    address->m_error = wxSOCKET_NOHOST;
+    return wxSOCKET_NOHOST;
+  }
+
+  memcpy( address->m_addr, info->ai_addr, info->ai_addrlen );
+  freeaddrinfo( info );
+  return wxSOCKET_NOERROR;
+}
+
+wxSocketError GAddress_INET6_SetAnyAddress(GAddress *address)
+{
+  assert(address != NULL);
+
+  CHECK_ADDRESS(address, INET6);
+
+  struct in6_addr addr;
+  memset( & addr, 0, sizeof( addr ) );
+  return GAddress_INET6_SetHostAddress(address, addr);
+}
+wxSocketError GAddress_INET6_SetHostAddress(GAddress *address,
+                                          struct in6_addr hostaddr)
+{
+  assert(address != NULL);
+
+  CHECK_ADDRESS(address, INET6);
+
+  ((struct sockaddr_in6 *)address->m_addr)->sin6_addr = hostaddr;
+
+  return wxSOCKET_NOERROR;
+}
+
+wxSocketError GAddress_INET6_SetPortName(GAddress *address, const char *port,
+                                       const char *protocol)
+{
+  struct servent *se;
+  struct sockaddr_in6 *addr;
+
+  assert(address != NULL);
+  CHECK_ADDRESS(address, INET6);
+
+  if (!port)
+  {
+    address->m_error = wxSOCKET_INVPORT;
+    return wxSOCKET_INVPORT;
+  }
+
+  se = getservbyname(port, protocol);
+  if (!se)
+  {
+    if (isdigit(port[0]))
+    {
+      int port_int;
+
+      port_int = atoi(port);
+      addr = (struct sockaddr_in6 *)address->m_addr;
+      addr->sin6_port = htons((u_short) port_int);
+      return wxSOCKET_NOERROR;
+    }
+
+    address->m_error = wxSOCKET_INVPORT;
+    return wxSOCKET_INVPORT;
+  }
+
+  addr = (struct sockaddr_in6 *)address->m_addr;
+  addr->sin6_port = se->s_port;
+
+  return wxSOCKET_NOERROR;
+}
+
+wxSocketError GAddress_INET6_SetPort(GAddress *address, unsigned short port)
+{
+  struct sockaddr_in6 *addr;
+
+  assert(address != NULL);
+  CHECK_ADDRESS(address, INET6);
+
+  addr = (struct sockaddr_in6 *)address->m_addr;
+  addr->sin6_port = htons(port);
+
+  return wxSOCKET_NOERROR;
+}
+
+wxSocketError GAddress_INET6_GetHostName(GAddress *address, char *hostname, size_t sbuf)
+{
+  struct hostent *he;
+  char *addr_buf;
+  struct sockaddr_in6 *addr;
+
+  assert(address != NULL);
+  CHECK_ADDRESS(address, INET6);
+
+  addr = (struct sockaddr_in6 *)address->m_addr;
+  addr_buf = (char *)&(addr->sin6_addr);
+
+  he = gethostbyaddr(addr_buf, sizeof(addr->sin6_addr), AF_INET6);
+  if (he == NULL)
+  {
+    address->m_error = wxSOCKET_NOHOST;
+    return wxSOCKET_NOHOST;
+  }
+
+  strncpy(hostname, he->h_name, sbuf);
+
+  return wxSOCKET_NOERROR;
+}
+
+wxSocketError GAddress_INET6_GetHostAddress(GAddress *address,struct in6_addr *hostaddr)
+{
+  assert(address != NULL);
+  assert(hostaddr != NULL);
+  CHECK_ADDRESS_RETVAL(address, INET6, wxSOCKET_INVADDR);
+  *hostaddr = ( (struct sockaddr_in6 *)address->m_addr )->sin6_addr;
+  return wxSOCKET_NOERROR;
+}
+
+unsigned short GAddress_INET6_GetPort(GAddress *address)
+{
+  assert(address != NULL);
+  CHECK_ADDRESS_RETVAL(address, INET6, 0);
+
+  return ntohs( ((struct sockaddr_in6 *)address->m_addr)->sin6_port );
+}
+
+#endif // wxUSE_IPV6
+
+/*
+ * -------------------------------------------------------------------------
+ * Unix address family
+ * -------------------------------------------------------------------------
+ */
+
+#ifndef __VISAGECPP__
+wxSocketError _GAddress_Init_UNIX(GAddress *address)
+{
+  address->m_len  = sizeof(struct sockaddr_un);
+  address->m_addr = (struct sockaddr *)malloc(address->m_len);
+  if (address->m_addr == NULL)
+  {
+    address->m_error = wxSOCKET_MEMERR;
+    return wxSOCKET_MEMERR;
+  }
+
+  address->m_family = wxSOCKET_UNIX;
+  address->m_realfamily = PF_UNIX;
+  ((struct sockaddr_un *)address->m_addr)->sun_family = AF_UNIX;
+  ((struct sockaddr_un *)address->m_addr)->sun_path[0] = 0;
+
+  return wxSOCKET_NOERROR;
+}
+
+#define UNIX_SOCK_PATHLEN (sizeof(addr->sun_path)/sizeof(addr->sun_path[0]))
+
+wxSocketError GAddress_UNIX_SetPath(GAddress *address, const char *path)
+{
+  struct sockaddr_un *addr;
+
+  assert(address != NULL);
+
+  CHECK_ADDRESS(address, UNIX);
+
+  addr = ((struct sockaddr_un *)address->m_addr);
+  strncpy(addr->sun_path, path, UNIX_SOCK_PATHLEN);
+  addr->sun_path[UNIX_SOCK_PATHLEN - 1] = '\0';
+
+  return wxSOCKET_NOERROR;
+}
+
+wxSocketError GAddress_UNIX_GetPath(GAddress *address, char *path, size_t sbuf)
+{
+  struct sockaddr_un *addr;
+
+  assert(address != NULL);
+  CHECK_ADDRESS(address, UNIX);
+
+  addr = (struct sockaddr_un *)address->m_addr;
+
+  strncpy(path, addr->sun_path, sbuf);
+
+  return wxSOCKET_NOERROR;
+}
+#endif  /* !defined(__VISAGECPP__) */
+#endif  /* wxUSE_SOCKETS */