???????????????????????????????????????java??.NET?????????????????????????????

????????????java????????????????C#???????????????TCP??Socket???????????????????????С?????????????????????????????????????飬?????????????????????????????к?????????????????飬????????????????????????????????????

??????????????????????????C#??java???????????????????????????????????????????????????????????????????????????а?????

???????????????java?????????????????


import java.net.*;
import java.io.*;

public class TCPCline{
 public static void main(String[] args) throws Exception{
  try{
   //?????IP????????????IP?????????????????
   Socket s = new Socket("IP???"?????);
   OutputStream os = s.getOutputStream();
   DataOutputStream dos = new DataOutputStream(os);
  
   String sendStr = "????hello";  
   //???????getBytes?????е?"UTF-8"
   byte[] bs = sendStr.getBytes("UTF-8");
    //??????????write??????????writeUTF????????????????????java????????????潲????
   dos.write(bs??0??bs.length);
   //??????????????????????????????????????????????????????????????????????????
   //dos.close();
   //s.close();
   }catch(ConnectException connExc){
    connExc.printStackTrace();
   
   }catch(IOException e){
    e.printStackTrace();
   }
 }
}
 


????C#???????????????????????£???????????????????????????TCPServer??

?????????????????????????????????????????????????????


using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace TCPServer
{
    /// <summary>
    /// ?????????
    /// </summary>
    public class LogHelper
    {
        public static readonly object objLock = new object();
       /// <summary>
       /// ??????д??.log?????
       /// </summary>
       /// <param name="msg">???????</param>
       /// <param name="ex">??</param>
        public static void Err(string msg?? Exception ex)
        {
            string s = "";
            if (ex != null)
            {
                s = "err:" + msg + ":" + ex.Message;
            }
            else
            {
               s = msg ;
            }
            //???????????log?????
            string filename = AppDomain.CurrentDomain.BaseDirectory + "log/" + Convert.ToString(getUnixTime()) + ".log";
            lock (objLock)
            {
                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(filename?? true))
                {
                    sw.WriteLine(s);
                    if (ex != null)
                    {
                        sw.WriteLine(ex.StackTrace);
                    }
                 
                    sw.WriteLine("time:" + DateTime.Now.ToString());
                    sw.WriteLine("----------------------------------");
                }
            }
        }