C#??????SOCKET????
???????????? ???????[ 2013/11/26 14:33:31 ] ????????
??????????????????SOCKET????????????????????IPEndPoint?????????????IP???????????????и???????????????????????????Щ??????????????80?????????????????????????????????????????????????????????????ī???????????????????SOCKET????????????????????????п?????????????е???????????????SOCKET????????accept()????????????????????????????????????????????????е?????????????????????????????????????????б????????byte[] bytr=Encoding.ASCII.GetBytes(string.ToArray) ?????string??????????????????????????????????????????????飬??????????????????????????receive??????????????????????????????????????????SOCKET?????????????????????????IPEndPoint???????????????????????????????????Щ???С???????????£?
????????????
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace GameServer
{
class Program
{
static void Main(string[] args)
{
Socket theConn;
IPAddress serverIp = IPAddress.Parse("127.0.0.1");
string Port = "8001";
Socket serverSocket = new Socket(AddressFamily.InterNetwork?? SocketType.Stream?? ProtocolType.Tcp);
IPEndPoint serverIpEnd = new IPEndPoint(serverIp?? Int32.Parse(Port));
serverSocket.Bind(serverIpEnd);
serverSocket.Listen(100);
while (true)
{
theConn = serverSocket.Accept();
byte[] receive = new byte[1024];
int i = theConn.Receive(receive?? 0?? theConn.Available?? SocketFlags.None);
//string id = Encoding.ASCII.GetString(receive?? 0?? i);
string id = Encoding.GetEncoding("GB2312").GetString(receive?? 0?? i);
Console.Write(id);
theConn.Close();
}
}
}
}
|
??????
![](/images/ad-banner/ad-banner.png)
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11