My blog
My LinkedIn Profile

BOOKS i'm reading

Napoleon Hill Keys to Success: The 17 Principles of Personal Achievement, Napoleon Hill, ISBN: 978-0452272811
The 4-Hour Workweek: Escape 9-5, Live Anywhere, and Join the New Rich (Expanded and Updated), Timothy Ferriss, ISBN: 978-0307465351
The Fountainhead, Ayn Rand, ISBN: 0452273331
Web Hosting Canada


Archives for: May 2007


Permalink 04:07:09 pm, by lano1106, 198 words, 2190 views   English (CA)
Categories: C++

C++ Member templates and template arguments

Every examples of member template that I have seen be it in the C++ Template book or in Mr. Stroustrup book consist of templatized copy constructors or assignment operators where the template argument can be deduced from the member function parameter. I wanted to write a member template with no function argument and I could not find in both mentionned books how such function could be called. Here is an example:

class A
    public :
    /* How do you call doX() ? */
    template <int ID> doX() {}

I have found out by experimenting that it is the exact same syntax than for function template:

A a;

I have written to the authors of the C++ Template book to point out this omission in their book and here is what David Vandervoorde has nicely answered:


Thanks for the feedback -- I think I agree.

Do not forget section 9.3.3 ("Dependent Names of Templates") in C++ Template, which may apply in cases like this. E.g., using your example as a basis:

template<typename T> void f(T x)
  x.template doX<1>();

Without that extra "template" keyword, the code would be invalid.



Permalink 10:32:37 am, by lano1106, 190 words, 3949 views   English (CA)
Categories: General, Video games

A new page in my career

Today is my last day at Quazal, the online gaming middleware provider. I have been working there for the last year and a half and have been involved in many projects such as the Relic Company of heroes lobby server, Supreme Commander, Atari Test Drive unlimited M.O.O.R. (Massively Open Online Racing) and Ubisoft Splinter Cell Conviction.

I am also the person who designed and implemented the generalized routing system that enhances peer-to-peer connectivity in Net-Z that Quazal should announce in the next few days. There are many purposes for this new feature. First, it allows developers to create online games in a client/server topology. Secondly, routing can be used in a peer-to-peer setup to enable the connectivity between players in the event that they would be behind NAT routers that make the connection impossible (any combination of strict and moderate NAT routers). As an extra bonus, Net-Z bandwidth usage has been optimized during the implementation of the new feature.

In two weeks, I will start to work at Stream the world on their audio/video streaming server. Its going to be very a very cool challenge!


Permalink 06:11:22 pm, by lano1106, 699 words, 16636 views   English (CA)
Categories: TCP/IP, Video games

NAT traversal for the dummies and the best NAT router for online gaming

A NAT router is a device that allow many computers to share the same IP address. You can learn more about NAT itself from Internetworking with TCP/IP, Vol 1 (5th Edition). One drawback of using NAT is that to communicate with someone outside the private network, you must initiate the communication from the private network. This is all fine for contacting a web server but this is making peer to peer applications such as file sharing or gaming harder. There are some techniques to perform NAT traversal but what makes the matter worse is that NAT routers have a different NAT behavior from a model to the other and as if it was not bad enough, these behaviors are totally undocumented. Things are about to change as the RFC 4787 describes a set of behaviors that a router should have to be gaming friendly. So my advice as a person who has worked at Quazal, a big well known multiplayer online middleware company, if you want the best NAT router for online gaming for your video game console (Xbox, Xbox360, Nintendo Wii, Playstation 2, Playstation 3 or PSP), you should look for a router that is RFC 4787 compliant. They might be hard to find now as the RFC has been released just few months ago but if I personnally was looking to purchase a new router, that is what I would be looking for.

The basic principle to perform NAT traversal is that you need a server on the public network that will be used as a traversal probe relay. Lets say that client A and client B that are located behind 2 distinct NAT routers. They first have to contact the server. The server must keep the address from which it receive data from the clients. These addresses are the public address of the clients behind the NAT router as seen from the server. When client A wants to establish a connection with client B, it will first request the client B public address from the server and start sending probes to B public address. At the same time, client A will send a request to B by using the server as a relay to start sending probes to itself. What will happen is since both clients try to establish a connection with each other at the same time, there should be a midair collision where a hole has been created for the other on each of their respective router. This technique is called hole punching and there is an RFC describing a protocol that implement this principle. The protocol name is STUN (Simple Traversal of UDP for NAT).

NAT traversal for TCP is much harder because TCP handshaking for establishing a connection is asymmetric. To workaround that problem, you have to trick the TCP protocol and the router that might monitor the TCP handshake. There is not yet an official protocol but some proposals exist. One of them is STUNT (STUN for TCP) but the name is funny because it has also a second meaning. The way STUNT works is that both side will initiate a connection by sending a SYN packet with a short TTL (Time To Live). The TTL value must be carefully choosen so the packet goes out of the private network but does not reach the destination. Then the stack itself or a packet sniffer must read the sequence number contained in the SYN message and send the read value to the STUNT server. The server will then impersonate the other endpoint and spoof the SYN/ACK reply. Then the last step of the connection which is to send the final ACK can be sent as usual and if everything has worked fine, the TCP connection will be established normally. I will stop the NAT traversal explanation here as there are a lot of good resources on the net. Here are the most interesting:

Update (12/05/2010): I have written a review of Linksys and a Netgear gaming router if it can help you to choose the right router for your needs.


Permalink 10:21:07 pm, by lano1106, 335 words, 1772 views   English (CA)
Categories: TCP/IP

SMTP client configuration

While setting up my Microsoft Outlook 2003 client to use my new hosting company, BlueHost, SMTP server, I was always getting a connection timeout every time I was clicking on the 'Test account settings'.

After investigating further the problem, I have found out that a TCP connection was established with the server but it was taking an unusual long time (around 35 seconds) before receiving the server '220' "Greeting" reply.

My first reflex has been to look into my book Internetworking with TCP/IP, Vol 1 (5th Edition) in the chapter on Electronic Mail and I have found:

If the server is overloaded, it may delay sending the 220 READY FOR MAIL message temporarily.

Then I went to check what the RFC 2821 text was saying about that topic and I have found in section Timeouts:

Based on extensive experience with busy mail-relay hosts, the minimum
per-command timeout values SHOULD be as follows:

Initial 220 Message: 5 minutes
An SMTP client process needs to distinguish between a failed TCP
connection and a delay in receiving the initial 220 greeting
message. Many SMTP servers accept a TCP connection but delay
delivery of the 220 message until their system load permits more
mail to be processed.

Here you go. The RFC recommends to set the timeout value to 5 minutes and the Microsoft Outlook 2003 default value found in the 'Advanced' tab of the 'More settings' dialog is one minute. I have tried to set it to 5 minutes and then I have retried to test my new settings again. The test was still failing. I have found out the reason. The server timeout seems to be hardcoded to 30 seconds or less when you click on the 'Test Account Settings...' button.

So, to make a long story short: If you have to connect to an overloaded SMTP server with Microsoft Outlook 2003 client (I do not know if there are other versions affected with this bug), the real test for your new account settings is not the test button but to actually try send manually a test e-mail.


Permalink 09:24:11 pm, by lano1106, 236 words, 1920 views   English (CA)
Categories: General

My big move is done


I have moved away from my free personal web page to a real hosting solution. It took a lot of time and energy and that distracted me from writting about programming but I am quite happy of the end result. It was well worth setting it up for the last week. Also as a bonus, I got a fully functionnal blog. I still have to tweak a small visual glitch on each side of the blog frame but after that, I will return to the main program that is writting about C++ programming. As a small teaser, the next covered topic is a small omission in the book C++ Templates from David Vandevoorde and Nicolai M. Josuttis that I reported to the authors which resulted to a nice exchange with Mr. Vandevoorde. Needless to say that this topic does not have a lot of coverage.

That being said, I must say publicly that I am totally impress with my new web hosting provider. The competition is probably ferocious but I could not beleive that I could get that much for only 6.95$ per month. This whole blog engine was part of the deal and on top of that, they have a very good and quick technical support be it ether on the phone or by e-mail. Anyway, I will stop the suspense in case that you would be curious now, I am talking about Bluehost.com

Olivier Langlois's blog

I want you to find in this blog informations about C++ programming that I had a hard time to find in the first place on the web.

May 2007
Sun Mon Tue Wed Thu Fri Sat
 << < Current> >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    


Custom Search


XML Feeds

What is RSS?

Who's Online?

  • Guest Users: 10

powered by