"Hello Julia" is sent just fine, but it doesn't include a newline, so the
readline on the server never terminates. Try println(client, "Hello Julia") or
write(client,"Hello Julia\n").


On Sun, Mar 23, 2014 at 3:11 PM, Collin Glass <[email protected]>wrote:

> I just started working on this again today, I've made a bit of progress in
> the client. I'm just not understanding how the client side sends data to
> the server.
>
> Server side:
>
> server = listen(8080)
> while true
>   conn = accept(server)
>   @async begin
>     try
>       while true
>         write(conn, "Hello Client!\n")
>         line = readline(conn)
>         write(conn,line)
>       end
>     catch err
>       print $err
>     end
>   end
> end
>
> And Client side:
>
> try
> client = connect(8080)
> print(readline(client))
> write(client, "Hello Julia")
>  print(readline(client))
> catch err
>   print("connection ended with error $err")
> end
>
> I get "Hello Client!" on my screen but I don't get the "Hello Julia". My
> hypothesis is that the line *write(client, "Hello Julia") is not the proper
> way to write to a server?
>
>
>
>
> On Wednesday, March 19, 2014 3:24:50 AM UTC-4, Collin Glass wrote:
>>
>> Thanks guys! My next question is how to write a client side?
>>
>> I'm creating a client.jl file with a few variations of the client code
>> found in the Networking and Streams doc:
>>
>> Something like this:
>>
>> try
>>   client = connect(8080)
>>   write(client, "Hello Julia")
>>   line = readline(client)
>>   print(line)
>> catch err
>>   print("connection ended with error $err")
>> end
>>
>> This might be a very general question, I am brand new to this language .
>> This is my first program :)
>>
>>
>>
>>
>> On Tuesday, March 18, 2014 11:18:05 AM UTC-4, Leah Hanson wrote:
>>>
>>> Oops! Sorry for that typo; I'll add the missing parens!
>>>
>>> Thanks for the bug report,
>>> Leah
>>>
>>>
>>> On Tue, Mar 18, 2014 at 2:41 AM, Ivar Nesje <[email protected]> wrote:
>>>
>>>> Because Julia does not have a print statement (just like the 3.X
>>>> versions of python).
>>>>
>>>> You will have to change the code to
>>>>
>>>> *print("connection ended with error $err")*
>>>> Ivar
>>>>
>>>>
>>>> kl. 07:55:45 UTC+1 tirsdag 18. mars 2014 skrev Collin Glass følgende:
>>>>
>>>>> I am just starting to use Julia and my first project I want to create
>>>>> a client for an AI hackathon.
>>>>>
>>>>> I want to know why the following echo server doesnt work.
>>>>>
>>>>> http://blog.leahhanson.us/using-tcp-sockets-in-julia.html
>>>>>
>>>>>
>>>>> I get the following error:
>>>>>
>>>>> ERROR: syntax: extra token """ after end of expression
>>>>>  in include at boot.jl:238
>>>>>  in include_from_node1 at loading.jl:114
>>>>>  in process_options at client.jl:303
>>>>>  in _start at client.jl:389
>>>>> at /Users/collinglass/code/julia/bombermanjl/bomberman.jl:11
>>>>>
>>>>
>>>

Reply via email to