本文整理汇总了C#中System.Net.IPEndPoint类的典型用法代码示例。如果您正苦于以下问题:C# System.Net.IPEndPoint类的具体用法?C# System.Net.IPEndPoint怎么用?C# System.Net.IPEndPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Net.IPEndPoint类属于命名空间,在下文中一共展示了System.Net.IPEndPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DotNetPosMain
/// <summary>
///
/// </summary>
/// <param name="endPointIP">Sender IPAddress</param>
/// <param name="endPointPort">Sender Port</param>
/// <param name="messageType">Message Type:
/// ISO8583.
/// XML.
/// EXCEL.</param>
public DotNetPosMain(string endPointIP, int endPointPort, MessageType messageType)
{
_msgType = messageType;
destinationEndPoint =
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(endPointIP), endPointPort);
}
示例2: WriteLog
public static void WriteLog(string sApplicationName, string sMsg)
{
lock (typeof(CarverLabUtility.Logger))
{
string FILENAME = @"c:\" + sApplicationName + ".log";
System.IO.StreamWriter fsw;
string sOut = "[" + System.DateTime.Now.ToString("G") + "] " + sMsg;
if (System.IO.File.Exists(FILENAME))
{
fsw = System.IO.File.AppendText(FILENAME);
}
else
{
fsw = System.IO.File.CreateText(FILENAME);
}
fsw.WriteLine(sOut);
fsw.Close();
System.Diagnostics.Trace.WriteLine(sMsg);
System.Net.IPEndPoint ipep = new System.Net.IPEndPoint(System.Net.IPAddress.Loopback,61288);
System.Net.Sockets.UdpClient uc = new System.Net.Sockets.UdpClient(System.Net.Sockets.AddressFamily.InterNetwork);
uc.Send(System.Text.Encoding.ASCII.GetBytes(sOut),sOut.Length,ipep);
}
}
示例3: Client
internal Client(NetStream stream, String user, Int32 sec, System.Net.IPEndPoint ip)
{
Stream = stream;
Username = user;
SecurityLevel = sec;
Ip = ip;
}
示例4: Main
static void Main(string[] args)
{
Client c = new Client();
try
{
//create a new client socket ...
c.m_socClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
String szIPSelected = "127.0.0.1";
String szPort = "8221";
int alPort = System.Convert.ToInt16(szPort, 10);
System.Net.IPAddress remoteIPAddress = System.Net.IPAddress.Parse(szIPSelected);
System.Net.IPEndPoint remoteEndPoint = new System.Net.IPEndPoint(remoteIPAddress, alPort);
c.m_socClient.Connect(remoteEndPoint);
String szData = "Hello There";
Console.WriteLine("Sending message");
byte[] byData = System.Text.Encoding.UTF8.GetBytes(szData);
c.m_socClient.Send(byData);
Console.WriteLine("Sent");
c.m_socClient.Close();
}
catch (SocketException se)
{
Console.WriteLine(se.Message);
}
}
示例5: connect_Click
private void connect_Click(object sender, EventArgs e)
{
byte[] buff = new byte[255];
System.Net.IPEndPoint IP = new System.Net.IPEndPoint(System.Net.IPAddress.Parse(txtIP.Text),Convert.ToInt32(txtPort.Text));
telnet.Connect(IP,txtsysop.Text,txtlock.Text);
timRecv.Enabled = true;
}
示例6: SDL
public SDL()
{
Initialise();
#region Connect To Server
System.Net.IPEndPoint tempIpAddress = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 8001);
Stromohab_MCE_Connection.TCPProcessor.ConnectToServer(tempIpAddress);
Stromohab_MCE_Connection.SendMCECommand.StartCameras();
Stromohab_MCE_Connection.TCPProcessor.JointListReceivedEvent += new Stromohab_MCE_Connection.TCPProcessor.JointListReceivedHandler(TCPProcessor_JointListReceivedEvent);
Stromohab_MCE_Connection.TCPProcessor.TrackableListReceivedEvent += new Stromohab_MCE_Connection.TCPProcessor.TrackableListReceivedHandler(TCPProcessor_TrackableListReceivedEvent);
#endregion Connect To Server
#region Remoting
//Register for events and pre-set all trackables to draw
ChannelServices.RegisterChannel(new TcpChannel(8008),false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(OpenGLViewer.OpenGLViewerRemoteControl), "Remote", WellKnownObjectMode.Singleton);
#endregion Remoting
}
示例7: Send
static void Send(List<GPSDataEntity> data ,string datatype)
{
MemoryStream ms = new MemoryStream();//创建内存流对象
new BinaryFormatter().Serialize(ms, data);//将序列化信息放入内存流
byte[] bytes = ms.ToArray();
string businessIP = ConfigHelper.GetConfig("businessServerIP");
int businessPort = int.Parse(ConfigHelper.GetConfig("businessserverport"));
string protocolType = ConfigHelper.GetConfig("protocolType");
if (protocolType == "udp")
{
System.Net.IPEndPoint business = new System.Net.IPEndPoint(System.Net.IPAddress.Parse(businessIP), businessPort);
udp.SendTo(business, bytes);
System.Console.WriteLine("udp send " + dataQty + " " + datatype + " " + bytes.Length + " bytes to business ok");
}
else if (protocolType == "tcp")
{
System.Net.Sockets.NetworkStream ns = tcp.GetStream();
ns.Write(bytes, 0, bytes.Length);
ns.Flush();
//ns.Close();
System.Console.WriteLine("tcp send " + dataQty + " " + datatype + " " + bytes.Length + " bytes to business ok");
}
System.Threading.Thread.Sleep(sendinterval);
}
示例8: RunServer
static void RunServer()
{
System.Net.IPEndPoint anyIP = new System.Net.IPEndPoint(System.Net.IPAddress.Any, 0);
System.Net.Sockets.UdpClient udpListener = new System.Net.Sockets.UdpClient(514);
byte[] bReceive; string sReceive; string sourceIP;
/* Main Loop */
/* Listen for incoming data on udp port 514 (default for SysLog events) */
while (true)
{
try
{
bReceive = udpListener.Receive(ref anyIP);
// Convert incoming data from bytes to ASCII
sReceive = System.Text.Encoding.ASCII.GetString(bReceive);
// Get the IP of the device sending the syslog
sourceIP = anyIP.Address.ToString();
// Start a new thread to handle received syslog event
new System.Threading.Thread(new logHandler(sourceIP, sReceive).handleLog).Start();
}
catch (System.Exception ex)
{
System.Console.WriteLine(ex.ToString());
}
} // Whend
} // End Sub Main
示例9: MainForm_Load
private async void MainForm_Load(object sender, EventArgs e)
{
var endPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Loopback, 1380);
var state = await RemoteServer.Instance.Connect(endPoint);
var version = state ? await RemoteServer.Instance.GetVersion() : null;
this.Text = state ? ("服务版本:" + version) : "连接服务器失败 ..";
this.btn_Login.Enabled = this.btn_Pass.Enabled = state;
}
示例10: ConnectToServer
public void ConnectToServer()
{
soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
//ipAdd = System.Net.IPAddress.Parse("10.1.70.50");
ipAdd = System.Net.IPAddress.Parse("192.168.0.18");
remoteEP = new System.Net.IPEndPoint(ipAdd, 1337);
soc.Connect(remoteEP);
}
示例11: Socket
public Socket(String host, int port)
{
System.Net.IPHostEntry hostEntry = System.Net.Dns.GetHostEntry (host);
System.Net.IPAddress serverIP = hostEntry.AddressList [0];
System.Net.IPEndPoint serverEP = new System.Net.IPEndPoint(serverIP,port);
this.delegateInstance = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp);
}
示例12: SetSettings
/// <summary>
/// will want to catch exception that occur in here and let someone know
/// </summary>
/// <param name="settings"></param>
public void SetSettings(ChiefMarleyControllerSettings settings)
{
// set addressing
System.Net.IPAddress ipAddr;
ipAddr = System.Net.IPAddress.Parse(settings.IpAddress);
System.Net.IPEndPoint endPoint = new System.Net.IPEndPoint(ipAddr, settings.Port);
addressing1.SetConnection(endPoint);
}
示例13: bw_DoWork
private void bw_DoWork(object sender, DoWorkEventArgs e)
{
try
{
byte[] buf;
if (random == true)
{
buf = System.Text.Encoding.ASCII.GetBytes(String.Format(Data, new Functions().RandomString()));
}
else
{
buf = System.Text.Encoding.ASCII.GetBytes(Data);
}
var RHost = new System.Net.IPEndPoint(System.Net.IPAddress.Parse(IP), Port);
while (IsFlooding)
{
Socket socket = null;
if (Protocol == 1)
{
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.NoDelay = true;
try { socket.Connect(RHost); }
catch { continue; }
socket.Blocking = Resp;
try
{
while (IsFlooding)
{
FloodCount++;
socket.Send(buf);
if (Delay >= 0) System.Threading.Thread.Sleep(Delay+1);
}
}
catch { }
}
if (Protocol == 2)
{
socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socket.Blocking = Resp;
try
{
while (IsFlooding)
{
FloodCount++;
socket.SendTo(buf, SocketFlags.None, RHost);
if (Delay >= 0) System.Threading.Thread.Sleep(Delay+1);
}
}
catch { }
}
}
}
catch { }
}
示例14: ConnectEvent
public void ConnectEvent()
{
Socket.ConnectEvent ev = EventFactory.CreateFromXml(TestEventXml.E084_Connect) as Socket.ConnectEvent;
Assert.That(ev, Is.Not.Null);
Assert.That(ev.Socket, Is.EqualTo(0x8ac));
System.Net.IPEndPoint expectedEndpoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("65.54.239.20"), 1863);
Assert.That(ev.RemoteEndPoint, Is.EqualTo(expectedEndpoint));
Assert.That(ev.Result, Is.EqualTo(Socket.ConnectResult.WouldBlock));
}
示例15: Main
static void Main(string[] args)
{
System.Net.IPEndPoint ep = new System.Net.IPEndPoint(System.Net.IPAddress.Any, 4004);
SyslogDaemon daemon = new SyslogDaemon(ep, Encoding.UTF8);
IServerStatus istatus = (IServerStatus)daemon;
ServerStatusLogger logger = new ServerStatusLogger(ref istatus, Encoding.UTF8);
logger.LogEntryAdded += new EventHandler<Just.EventArguments.StringEventArgs>(logger_LogEntryAdded);
daemon.StartReceiving();
Console.Read();
}