Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Julia 1.0 Programming

You're reading from   Julia 1.0 Programming Dynamic and high-performance programming to build fast scientific applications

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher
ISBN-13 9781788999090
Length 196 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ivo Balbaert Ivo Balbaert
Author Profile Icon Ivo Balbaert
Ivo Balbaert
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Installing the Julia Platform FREE CHAPTER 2. Variables, Types, and Operations 3. Functions 4. Control Flow 5. Collection Types 6. More on Types, Methods, and Modules 7. Metaprogramming in Julia 8. I/O, Networking, and Parallel Computing 9. Running External Programs 10. The Standard Library and Packages 11. Other Books You May Enjoy

Working with TCP sockets and servers


To send data over a network, the data has to conform to a certain format or protocol. The Transmission Control Protocol / Internet Protocol (TCP/IP) is one of the core protocols to be used on the internet.

The following screenshot shows how to communicate over TCP/IP between a Julia TCP server and a client (see the code in Chapter 8\tcpserver.jl):

The server (in the upper-left corner) is started in a Julia session with server = Sockets.listen(8080), which returns a TcpServer object listening on port 8080. The conn = accept(server) line waits for an incoming client to make a connection. In a second terminal (in the lower-right corner), we start the netcat (nc) tool at the prompt to make a connection with the Julia server on port 8080, for example, nc localhost 8080. Then, the accept function creates a TcpSocket object on which the server can read or write.

Then, the server issues the line = readline(conn) command, blocking the server until it gets a full...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime