Added start of networkhandler and apihandler

This commit is contained in:
jancoow
2015-10-15 13:02:50 +02:00
parent 67c7e13812
commit 72c75b457d
2 changed files with 45 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApplication2
{
class APIHandler
{
}
}
+33
View File
@@ -0,0 +1,33 @@
using System.Text;
using System.Net.Sockets;
namespace WindowsFormsApplication2
{
class NetworkHandler
{
private int port = 8585;
private Socket s;
public NetworkHandler(string ip)
{
s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Connect(ip, port);
}
public void SendString(string m)
{
byte[] req_as_bytes = Encoding.UTF8.GetBytes(m);
s.Send(req_as_bytes);
}
public void ReceiveData()
{
while (s.Connected)
{
byte[] data = new byte[1024 * 200];
int t = s.Receive(data);
//Iets doen met api calls
}
}
}
}