# Question about Sockets.jl on two versions (julia1.10.5 vs julia1.11.5)

**URL:** <https://discourse.julialang.org/t/question-about-sockets-jl-on-two-versions-julia1-10-5-vs-julia1-11-5/131355>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 5, 2025, 4:28am UTC](https://discourse.julialang.org/t/question-about-sockets-jl-on-two-versions-julia1-10-5-vs-julia1-11-5/131355 "2025-08-05T04:28:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sole](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sole/32/202974_2.png) [@Sole](https://discourse.julialang.org/u/Sole)\
**Post date:** [August 5, 2025, 4:28am UTC](https://discourse.julialang.org/t/question-about-sockets-jl-on-two-versions-julia1-10-5-vs-julia1-11-5/131355/1 "2025-08-05T04:28:37Z")

</div>

When I transfer datas between a server and a client using julia1.10.5, Sockets.jl works well, but when I running the same code on julia1.11.5, Sockets.jl gives abnormal results. Here is my code:

```julia
using Sockets

const START = "<s>"
const FINAL = "<e>"
const ENCODING = UInt8

const lstart = length(START)
const lfinal = length(FINAL)

ipv4 = IPv4(127, 0, 0, 10)
port = 8000

"""
    putdata(sock::TCPSocket, data::Vector{Float32})
data transfer protocol:
<s> * length_of_data * data * <e>
"""
function putdata(sock::TCPSocket, data::Vector{Float32})
    try
        HEAD = transcode(ENCODING, START)
        TAIL = transcode(ENCODING, FINAL)
        SIZE = UInt32(sizeof(data))
        write(sock, HEAD) # sending head of protocol
        write(sock, SIZE) # number of bytes to send
        write(sock, data) # sending data
        write(sock, TAIL) # sending tail of protocol
        return true
    catch err
        @error "sending errors" err
        return false
    end
end

function getdata(sock::TCPSocket)
    buffer = Vector{UInt8}()
    is_start_found = false

    # looking for the head of protocol
    while !is_start_found
        push!(buffer, read(sock, UInt8))
        lbuf = length(buffer)
        if lbuf ≥ lstart
            mark = String(buffer[lbuf+1-lstart : lbuf])
            if isequal(mark, START)
                is_start_found = true
                empty!(buffer)
            end
        end
    end

    # read the number of bytes of data
    databytes = read(sock, UInt32)
    if !iszero(databytes % 4)
        @warn "not legal length"
        return Float32[]
    end
    
    # read data
    data = read(sock, databytes)

    # check the tail mark
    mark = String(read(sock, lfinal))
    if !isequal(mark, FINAL)
        @warn "end mark mismatch (data may be corrupted)"
        return Float32[]
    end

    return reinterpret(Float32, data)
end

```

then is the server end:

```julia
function run_server(ip::IPv4, port::Int)
    server = listen(ip, port)
    
    try
        while true
            sock = accept(server)
            @async begin
                while isopen(sock)
                    # recive and respond
                    data = getdata(sock)
                    write(sock, sum(data))

                    # sending data to client
                    len = rand(30000:80000)
                    data = randn(Float32, len)
                    issent = putdata(sock, data)

                    # check the sum
                    if issent
                        localsum = sum(data)
                        cloudsum = read(sock, Float32)
                        delta = localsum - cloudsum
                        !iszero(delta) && println("error: ", delta)
                        # println("$localsum $cloudsum")
                    end
                end
            end
        end
    catch err
        println("server shut down unexpectedly")
    finally
        close(server)
    end
end

```

then is the client end

```julia
function run_client(ip::IPv4, port::Int, niters::Int=100)
    sock = connect(ip, port)
    try
        for iter ∈ 1 : niters
            # send data to server
            len = rand(30000:80000)
            data = randn(Float32, len)
            issent = putdata(sock, data)

            # check the sum
            if issent
                localsum = sum(data)
                cloudsum = read(sock, Float32)
                delta = localsum - cloudsum
                !iszero(delta) && println("error: ", delta)
                # println("$localsum $cloudsum")
            end

            # recive and respond too
            data = getdata(sock)
            write(sock, sum(data))
        end
    catch err
        println("disconnected")
    finally
        close(sock)
    end
end

```

finally I run the `run_server(ipv4, port)` in one terminal, and run `run_client(ipv4, port, 100)` in another terminal, and things happend that julia1.10.5 doesn’t execute `println("error ", delta)` while julia1.11.5 execute `println("error ", delta)` with `delta` very close to zero like

```julia
error: -0.0001373291
error: -7.6293945e-5
error: -0.00014686584
...

```

so is there any difference between 1.10.5 and 1.11.5 ? 🧐
