Click here to Skip to main content
15,893,508 members
Articles / Programming Languages / C#

Failover Socket Client

Rate me:
Please Sign up or sign in to vote.
4.82/5 (10 votes)
20 Aug 2007CPOL9 min read 53.6K   786   47  
A socket client which fails over to a different host when the connection drops
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2006 rel. 3 sp2 (http://www.altova.com) by Bart Meirens (Webappexpert) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:element name="configuration">
		<xs:annotation>
			<xs:documentation>The root element for the configuration file</xs:documentation>
		</xs:annotation>
		<xs:complexType>
			<xs:sequence>
				<xs:element name="hosts" type="hosts"/>
				<xs:element name="backupFile">
					<xs:annotation>
						<xs:documentation>The file name (including path) to save unsent messages to</xs:documentation>
					</xs:annotation>
					<xs:simpleType>
						<xs:restriction base="xs:string">
							<xs:whiteSpace value="collapse"/>
						</xs:restriction>
					</xs:simpleType>
				</xs:element>
				<xs:element name="logPath">
					<xs:annotation>
						<xs:documentation>The path where log files should be saved</xs:documentation>
					</xs:annotation>
					<xs:simpleType>
						<xs:restriction base="xs:string">
							<xs:whiteSpace value="collapse"/>
						</xs:restriction>
					</xs:simpleType>
				</xs:element>
				<xs:element name="interval">
					<xs:annotation>
						<xs:documentation>The interval in miliseconds after which a connection check is performed</xs:documentation>
					</xs:annotation>
					<xs:simpleType>
						<xs:restriction base="xs:long">
							<xs:whiteSpace value="collapse"/>
							<xs:minExclusive value="0"/>
						</xs:restriction>
					</xs:simpleType>
				</xs:element>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<!--*************************************
	     *                 host                    *
         *************************************-->
	<xs:complexType name="host">
		<xs:annotation>
			<xs:documentation>The host represented by its IP address and port number</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="IP">
				<xs:simpleType>
					<xs:restriction base="xs:string">
						<xs:maxLength value="15"/>
						<xs:whiteSpace value="collapse"/>
						<xs:pattern value="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"/>
					</xs:restriction>
				</xs:simpleType>
			</xs:element>
			<xs:element name="port">
				<xs:simpleType>
					<xs:restriction base="xs:nonNegativeInteger">
						<xs:whiteSpace value="collapse"/>
					</xs:restriction>
				</xs:simpleType>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<!--**************************************
	     *                 hosts                    *
         **************************************-->
	<xs:complexType name="hosts">
		<xs:annotation>
			<xs:documentation>The hosts portion of the configuration file</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="host" type="host" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>
</xs:schema>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Europe Europe
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions