Patrick’s development blog

Simple Ubuntu speed-up tweak

Posted in Linux/GNU by Patrick on April 25, 2008

I recently searched around for some Ubuntu speed-up tips in order to speed up my Ubuntu computer. I found an interesting thing, it’s considered a bug that slows down the application start-up time and performance considerably.

The tweak/bug

Open the /etc/hosts file as root using any texteditor and replace the following line: localhost

With the name of your computer: localhost computername

Read more about the bug at this site:


Day 2: Handle code using classes

Posted in Uncategorized by Patrick on April 16, 2008

I’m currently trying to create a thread for the client that receives messages from the server. These messages are later going to be sent to all the clients currently connected to the server, but for now it only sends to one client. The client class is almost finished, there are only some small details left. I haven’t done much on the server part of the class yet, i’ll do that next time I work on this project.

This is how my client looks like right now.


#include “client.h”

SDL_Surface *screen = NULL;
SDL_Event event;

int main(int argc, char* args[]) {
if (SDLNet_Init() < 0) {
std::cout << SDLNet_GetError();

std::cout << “SDL_net was initialized sucessfully!” << std::endl;

IPaddress ip;
TCPsocket tcpsock;
const int PORT = 2000;
char buffer[512];

if (SDLNet_ResolveHost(&ip, “localhost”, PORT) < 0) {
std::cout << “SDLNet_ResolveHost: ” << SDLNet_GetError();

std::cout << “Resolved host at port ” << PORT << std::endl;

tcpsock = SDLNet_TCP_Open(&ip);
if (!tcpsock) {
std::cout << “SDLNet_TCP_Open: ” << SDLNet_GetError();

std::cout << “Connected to server using a TCP-socket on port ” << PORT << std::endl;

bool done = false;

Client client_h(tcpsock); // this class is used to receive messages from the server sort of

while (!done) {
std::cout <“;
std::cin.getline(buffer, 512);

if (SDLNet_TCP_Send(tcpsock, static_cast(buffer), 512) < 512) {
std::cerr << “SDLNet_TCP_Send: ” << SDLNet_GetError();
return 0;


return 0;

I’ll write about SDL_Net in more detail another time. Right now i’m fully occupied with this project. Things are going more smootly now though.

Chat App Day 1: SDLNet and networking

Posted in Uncategorized by Patrick on April 15, 2008

I started coding on my network application again this week. Things have gone very slow, I was getting confused with the library I used so I decided today that I would go back to the first library I had in mind and make a fresh start. I’m using the cross-platform library SDL_Net which is a part of my favourite library SDL (

About four or five weeks ago when I attempted to make the very first part of my chat application in SDL, I didn’t have any idea at all how I would build it. After that i’ve gone trough many different libraries, trying to find the one which best suited my needs. This time, i’ve gotten some information about networked applications in general after all this testing and to my own surprise I managed to build a simple application where you can send messages to a server with many clients, that are handled using threads.

There is still a long way to go, but I sort of know what to implement now and most importantly HOW to implement it. I’m going to make the basic application first and after that make it object-oriented. I’m glad that I managed in one hour, what I couldn’t in 5-7 hours before, i’ve learned a lot : )

I’m going to make a post tomorrow with the code I got so far. I made a fresh start with this project, so I won’t post my old code however. I’m going to restart this project after all.