jay_eire
asked on
monitor my connections
Is this possible? if so, how can I do it,
Thanks
Jay Eire
(<>..<>)
I need something to monitor my connections, if the connection dies or collapses I need it to automatically open back up again. Also is the any type of Connection Manager Class or Code out there I could use......... here's what I have..........
using System;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
using Microsoft.VisualBasic;
namespace TCPConnection
{
/// <summary>
/// Summary description for MYTCPConnection.
/// </summary>
public class MYTCPConnection
{
private Socket MySocket;
public MYTCPConnection()
{
//
// TODO: Add constructor logic here
//
}
public void Connectsocket()
{
IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostNam e());
//IPAddress ipAddress = ipHostInfo.AddressList[0];
IPAddress ipAddress = IPAddress.Parse("12.8.19.4 4");
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 1002);
Socket tempsocket = new Socket(AddressFamily.Inter Network,
SocketType.Stream, ProtocolType.Tcp );
tempsocket.Connect(localEn dPoint);
if (tempsocket.Connected)
{
MySocket = null;
MySocket = tempsocket ;
}
}
public void DisConnectSocket()
{
MySocket.Close();
}
public string SocketSendReceive(string ToSend)
{
//Set up variables and String to write to the server.
byte[] bytesReceived = new Byte[2500];
byte[] bytesSent = Encoding.Unicode.GetBytes( ToSend);
// Send request to the server.
int i = MySocket.Send(bytesSent);
// Receive the server home page content.
int bytes ;
// Read the first 256 bytes.
string page = "";
//The following will block until the page is transmitted.
try
{
bytes = MySocket.Receive(bytesRece ived);
page = Encoding.Unicode.GetString (bytesRece ived, 0, bytes);
return page;
}
catch(Exception)
{
int iErr = 0;
iErr = 1;
}
return "OK";
}
}
}
Thanks
Jay Eire
(<>..<>)
I need something to monitor my connections, if the connection dies or collapses I need it to automatically open back up again. Also is the any type of Connection Manager Class or Code out there I could use......... here's what I have..........
using System;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
using Microsoft.VisualBasic;
namespace TCPConnection
{
/// <summary>
/// Summary description for MYTCPConnection.
/// </summary>
public class MYTCPConnection
{
private Socket MySocket;
public MYTCPConnection()
{
//
// TODO: Add constructor logic here
//
}
public void Connectsocket()
{
IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostNam
//IPAddress ipAddress = ipHostInfo.AddressList[0];
IPAddress ipAddress = IPAddress.Parse("12.8.19.4
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 1002);
Socket tempsocket = new Socket(AddressFamily.Inter
SocketType.Stream, ProtocolType.Tcp );
tempsocket.Connect(localEn
if (tempsocket.Connected)
{
MySocket = null;
MySocket = tempsocket ;
}
}
public void DisConnectSocket()
{
MySocket.Close();
}
public string SocketSendReceive(string ToSend)
{
//Set up variables and String to write to the server.
byte[] bytesReceived = new Byte[2500];
byte[] bytesSent = Encoding.Unicode.GetBytes(
// Send request to the server.
int i = MySocket.Send(bytesSent);
// Receive the server home page content.
int bytes ;
// Read the first 256 bytes.
string page = "";
//The following will block until the page is transmitted.
try
{
bytes = MySocket.Receive(bytesRece
page = Encoding.Unicode.GetString
return page;
}
catch(Exception)
{
int iErr = 0;
iErr = 1;
}
return "OK";
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
what i need to do is monitor my connection, if it closes i need to reopen the connection immediately
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER