日期:2014-05-17 浏览次数:21556 次
/**
*这里假设的例子是普通的登录功能
*/
//客户端通过socket发送ID和pass
Socket socket = new socket(ip,port);
DataOutputStream dos=new DataOutputStream(socket.getOutputStream());
DataInputStream dis=new DataInputStream(socket.getInputStream());
dos.writeInt(ID);
dos.writeUTF(pass);
String Name = dis.readUTF();//读取
System.out.println(teamName);
//服务器端返回用户名字
ServerSocket serverSocket=new ServerSocket(port);//服务器的监听端口
Socket socket = new Socket();
socket = serverSocket.accept();//accept()类似迭代器作用的获取
DataOutputStream dos=new DataOutputStream(socket.getOutputStream());
DataInputStream dis=new DataInputStream(socket.getInputStream());
int ID = dis.readInt();
String pass = dis.readUTF();
dos.writeUTF(Name);//name是数据库查询得到的结果
string input = "Hello World!";
char[] values = input.ToCharArray();
foreach (char letter in values)
{
// Get the integral value of the character.
int value = Convert.ToInt32(letter);
// Convert the decimal value to a hexadecimal value in string form.
string hexOutput = String.Format("{0:X}", value);
Console.WriteLine("Hexadecimal value of {0} is {1}", letter, hexOutput);