Added start of networkhandler and apihandler
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WindowsFormsApplication2
|
||||||
|
{
|
||||||
|
class APIHandler
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user