[SOLVED] How to make a simple server-client setup?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Ragerin
Prole
Posts: 9
Joined: Fri Feb 22, 2013 8:24 am
Location: Denmark

[SOLVED] How to make a simple server-client setup?

Post by Ragerin »

Hello.

I have been searching for a good tutorial, on how to create a simple TCP server-client setup, with LUBE (the newest version, requiring Common Class) and LÖVE.

What I want to achieve, is to have a server running on some port and a client to connect to that server. When the connection happens, the client sends a string to the server, which is then printed into the console of the server (and vice versa).


I have been working a little with sockets in Python and got it easily working. But I find it really difficult to find any tutorials and/or guides on how to achieve the very most simple networking setup with LÖVE and LUBE.



I have uploaded my test-file. I hope to achieve a server-application with a GUI.
In this current test-file, I have both the server and client in the same file. I don't know if that is a problem?

I really hope someone can enlighten me or help me with an up-to-date guide on how to do this, since I can't - after months of searching and trying - seem to get it working, at all...


Cheers! And have a nice day. :-D
Attachments
game.love
(158.49 KiB) Downloaded 233 times
Last edited by Ragerin on Fri Apr 12, 2013 8:25 am, edited 1 time in total.
Zeliarden
Party member
Posts: 139
Joined: Tue Feb 28, 2012 4:40 pm

Re: How to make a simple server-client setup?

Post by Zeliarden »

Yo!
you call

Code: Select all

connection = lube.tcpServer()
and then later overwrite it with

Code: Select all

connection = lube.tcpClient()
call the later client or something

then do something like

Code: Select all

function love.update(dt)
	loveframes.update(dt)
	
	if connection then --udates server
		connection:update(dt)
	end
	
	if client then --updates client and sends
		client:update(dt)
		client:send("tomte")
	end
	
end
User avatar
Ragerin
Prole
Posts: 9
Joined: Fri Feb 22, 2013 8:24 am
Location: Denmark

Re: How to make a simple server-client setup?

Post by Ragerin »

Thank you!

That did the trick. I am starting to understand how to use the LUBE-library.

Hopefully this thread will also help other new Lövers understand how to do networking. :-)


Marking the thread as solved.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests