diff --git a/src/xpdev/ini_file.c b/src/xpdev/ini_file.c
index 76e254ebfd830eff3c1935e971d7eff5980a1cda..c00289dd0f78bc0fde460e02369ad0f37b914313 100644
--- a/src/xpdev/ini_file.c
+++ b/src/xpdev/ini_file.c
@@ -39,9 +39,6 @@
 #include <string.h>		/* strlen */
 #include <ctype.h>		/* isdigit */
 #include <math.h>		/* fmod */
-#if !defined(NO_SOCKET_SUPPORT)
-	#include "sockwrap.h"	/* inet_addr */
-#endif
 #include "datewrap.h"	/* isoDateTime_t */
 #include "dirwrap.h"	/* fexist */
 #include "filewrap.h"	/* chsize */
@@ -1096,6 +1093,53 @@ ulong iniGetBytes(str_list_t list, const char* section, const char* key, ulong u
 
 #if !defined(NO_SOCKET_SUPPORT)
 
+int iniGetSocketOptions(str_list_t list, const char* section, SOCKET sock
+						 ,char* error, size_t errlen)
+{
+	int			i;
+	int			result;
+	char*		name;
+	BYTE*		vp;
+	socklen_t	len;
+	int			option;
+	int			level;
+	int			value;
+	LINGER		linger;
+	socket_option_t* socket_options=getSocketOptionList();
+
+	for(i=0;socket_options[i].name!=NULL;i++) {
+		name = socket_options[i].name;
+		if(!iniValueExists(list, section, name))
+			continue;
+		value=iniGetInteger(list, section, name, 0);
+
+		vp=(BYTE*)&value;
+		len=sizeof(value);
+
+		level	= socket_options[i].level;
+		option	= socket_options[i].value;
+
+		if(option == SO_LINGER) {
+			if(value) {
+				linger.l_onoff = TRUE;
+				linger.l_linger = value;
+			} else {
+				ZERO_VAR(linger);
+			}
+			vp=(BYTE*)&linger;
+			len=sizeof(linger);
+		}
+
+		if((result=setsockopt(sock,level,option,vp,len)) != 0) {
+			safe_snprintf(error,errlen,"%d setting socket option (%s, %d) to %d"
+				,ERROR_VALUE, name, option, value);
+			return(result);
+		}
+	}
+
+	return(0);
+}
+
 static ulong parseIpAddress(const char* value)
 {
 	if(strchr(value,'.')==NULL)
diff --git a/src/xpdev/ini_file.h b/src/xpdev/ini_file.h
index 9f1f66a867f35530306c0ffa9ec2c2089d1a44f3..09e621b3df286992003e57c3be3df19affc4324a 100644
--- a/src/xpdev/ini_file.h
+++ b/src/xpdev/ini_file.h
@@ -40,6 +40,9 @@
 
 #include "genwrap.h"
 #include "str_list.h"	/* strList_t */
+#if !defined(NO_SOCKET_SUPPORT)
+	#include "sockwrap.h"	/* inet_addr, SOCKET */
+#endif
 
 #define INI_MAX_VALUE_LEN	1024		/* Maximum value length, includes '\0' */
 #define ROOT_SECTION		NULL
@@ -154,6 +157,8 @@ double		iniGetNamedFloat(str_list_t, const char* section, const char* key
 ulong		iniGetBitField(str_list_t, const char* section, const char* key
 					,ini_bitdesc_t* bitdesc, ulong deflt);
 #define		iniGetLogLevel(l,s,k,d) iniGetEnum(l,s,k,iniLogLevelStringList(),d)
+int			iniGetSocketOptions(str_list_t, const char* section
+					,SOCKET sock, char* error, size_t errlen);
 
 void		iniSetDefaultStyle(ini_style_t);