public Connection(string host, int display) { string hst; int dpy, scr; Trace.Listeners.Add(new TextWriterTraceListener(Console.Error)); ParseDisplay(null, out hst, out dpy, out scr); sock = Open(hst, dpy); //Auth.Xauth auth = Auth.Xau.GetAuthByAddr (sock.RemoteEndPoint.Serialize (), "0"); Auth.Xauth auth = Auth.Xau.GetAuthByHack(hst, dpy); ConnectToSocket(sock, auth); }
public void ConnectToSocket(Socket sock, Auth.Xauth auth_info) { sock.Blocking = false; xrr = new XResponseReader(stream); xw = new XWriter(stream); xrr.sock = sock; xw.sock = sock; xrr.fd = (int)sock.Handle; xw.fd = (int)sock.Handle; WriteSetup(auth_info); ReadSetup(); }
void WriteSetup(Auth.Xauth auth_info) { ConnSetupReq o = new ConnSetupReq(); /* B = 0x42 = MSB first, l = 0x6c = LSB first */ //MSB //o.ByteOrder = 0x42; //LSB //o.ByteOrder = 0x6c; o.ByteOrder = 0x6c; o.ProtocolMajorVersion = X_PROTOCOL; o.ProtocolMinorVersion = X_PROTOCOL_REVISION; if (auth_info != null) { o.AuthorizationProtocolNameLen = (ushort)auth_info.Name.Length; o.AuthorizationProtocolDataLen = (ushort)auth_info.Data.Length; o.AuthorizationProtocolName = auth_info.Name; o.AuthorizationProtocolData = auth_info.Data; } xw.Send(o, false); }