日期:2014-05-17 浏览次数:25209 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace server_1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
IPAddress IPadd = IPAddress.Parse("192.168.2.138");
TcpListener tcplistener = new TcpListener(IPadd, 1111);
tcplistener.Start();
TcpClient tcpclient = tcplistener.AcceptTcpClient();
NetworkStream ns = tcpclient.GetStream();
StreamReader sr = new StreamReader(ns);
String test = sr.ToString();
textBox1.Text = test;
}
}
}
var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Bind(new IPEndPoint(IPAddress.Any, int.Parse(txt_port.Text)));
IPAddress.Any