Send/Recieve bytes client/Server Unity Unet
Hi im having some issues sending/Recieving byte arrays with server and client. the idea is when the client presses a button it sends a string to the server and the server checks username/password in a database then returns login info to the client.
i havent had success with this yet and i have checked the API and havent found any useful info, i have been able to do this with .Net Sockets but unity doesnt use the full library and i have had a lot of issues getting it to run along side unity code so im looking at how Unet does it with byte Arrays.
some help would be greatly appreciated as much as a small example of just sending/Recieving bytes for a client/server.
i had attempted this
void Login() {
string msg = "Hello Server!";
byte[] data = Encoding.ASCII.GetBytes(msg);
//int chanId = 0;
//client.SendBytes(data, data.Length, 0);
NetworkWriter writer = new NetworkWriter();
writer.Write(data, 0, buffer.Length);
}
and in update
void Update() { NetworkReader reader = new NetworkReader();
buffer = reader.ReadBytes(1024); print(Encoding.ASCII.GetString(buffer)); }
going off the APi, i havent had much luck digging through the confusing material, so was hoping someone here could help out.