I’m hoping to send a jpeg file from matlab to unity to use it as Texture.
I used the code on manual but it doesn’t receive anything. what to do?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Net;
using System.Net.Sockets;
using System;
using System.IO;public class Socket : MonoBehaviour {
// Use this for initialization
internal Boolean socketReady = false;
TcpClient mySocket;
NetworkStream theStream;
StreamWriter theWriter;
StreamReader theReader;
String Host = "localhost";
Int32 Port = 53000;
void Start () {
setupSocket ();
Console.Write ("socket is set up");
}
// Update is called once per frame
void Update () {
}
public void setupSocket() {
try {
mySocket = new TcpClient(Host, Port);
theStream = mySocket.GetStream();
theWriter = new StreamWriter(theStream);
socketReady = true;
//writeSocket("yah!! it works");
Console.Write ("socket is sent");
}
catch (Exception e) {
Debug.Log("Socket error: " + e);
}
}
}