End Google Ads 201810 - BS.net 01 --> Hi,

I have written the below code to connect to the server.Also I should login to the server to fetch data from it.How to supply credentials via socket so that the server allows the client to fetch the data from server.

byte[] receivedBytes = new byte[1024]; int portno = Convert.ToInt32(txtportnum.Text); IPHostEntry ipHost = Dns.GetHostByName("192.168.x.y"); IPAddress ipAddress = ipHost.AddressList[0]; IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, portno); txtstatus.Text = "Creating socket object..."; Socket send_soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream,ProtocolType.Tcp); send_soc.Connect(ipEndPoint); txtstatus.AppendText("\nSuccessfully connected to:" + "\t" + send_soc.RemoteEndPoint); txtstatus.AppendText("\nConnecting via :" + "\t" + send_soc.LocalEndPoint); string sendingMessage = "abcde"; SendMessage(send_soc, sendingMessage); int totalBytesReceived = send_soc.Receive(receivedBytes); string dff = ""; string s = System.Text.UTF7Encoding.UTF7.GetString(receivedBytes, 0, totalBytesReceived); txtRx.AppendText(s); send_soc.Shutdown(SocketShutdown.Both); send_soc.Close(); try { FileStream dr = new FileStream("E:/Demo/IpData/Call.txt", FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite); StreamReader fg = new StreamReader(dr); string df = fg.ReadToEnd(); dff = df; fg.Dispose(); dr.Dispose(); } catch (Exception dfjdfs) { throw dfjdfs; } try { File.Delete("E:/Demo/IpData/Call.txt"); } catch (Exception jhu) { throw jhu; } try { FileStream cd = new FileStream("E:/Demo/IpData/Call.txt", FileMode.Create); StreamWriter cdf = new StreamWriter(cd); cdf.Write(dff); cdf.Write(s); cdf.Dispose(); cd.Dispose(); } catch (Exception hgy) { throw hgy; } }
Any guidance on how to supply credentials will be of great help.