Client tcp receiving jpeg file

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);
        }
    }
}

I read this thread a while ago and wasn’t sure how to respond.
If that is your code in its entirety, it’s never receiving anything.
Does it print “Socket is sent” ?

PS. I don’t think you should name your class ‘Socket’, which is a built-in type. I always find that highly confusing. :slight_smile:

Yea it prints nothing! this is the code I found on unity manual…

Not sure about that; that code needs a server to be listening, also.
You don’t see any console messages at all from that script? Is the script on a game object?

What I was trying to say also was that that script never sends or receives any information from the tcp client / socket. So, it could be partially working, but couldn’t possibly be doing what you had hoped (not yet at least).