UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2013-10-24 10:18 AM

RipRage
Member
From: England
Registered: 2010-01-06
Posts: 146

Linux

Random one, I've fallen in love with Linux: Luna! What a beautiful distro! Yeah I know it's not your "I want to configure the living shit out of everything!" Type distro by why should it be!? I can see myself replacing windows with this eventually, what do you guys use?

Offline

#2 2013-10-24 12:07 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Linux

Huh, I've never even heard of Luna before...

I've pretty much been a Red Hat user forever...  In the early days, we used Slackware on a couple servers, but since then it's been Red Hat all the way...  These days that comes in the form of CentOS, since we're not rich/crazy enough to pay for official RHEL support... ;-)  But, I mainly only run CentOS on my personal workstation due to the fact I need to write code to run on CentOS servers at work, so it makes things easier to be able to get things up and running here in the same environment...  Otherwise, I'd probably run a more modern desktop-friendly distro like Fedora or maybe even Ubuntu...  (Though, the only reason I'd consider Ubuntu is because it was the recommended distro for use with Valve's Steam Linux client and their games...  Though, these days I think it works on most modern distros...  Plus, they're releasing their own custom distro called SteamOS sometime soon...  Though, really, before even thinking about gaming, I'd really need a new, faster PC, because my current one is getting pretty ancient...)

I dropped all MS ties not long after Win95 came out!  I used to be a fairly happy DOS user, but absolutely loathed Windows and the general direction MS was heading...  As soon as id got QuakeWorld running on Linux and announced that Quake 2 and 3 would definitely be released on Linux, that was all the push I needed to dump Windows and install Linux (I think it was Red Hat 5, at the time; not RHEL5 mind you, but old school RH personal edition 5)...  Yes, I've always been somewhat driven by gaming when it comes to my computer... ;-)  Though, these days, pretty much the only gaming I really do anymore is on my Xbox360...  So, I guess MS still has their hooks in me via that!  But, as long as I don't have to use it for doing any real work or really anything but gaming, I can tolerate it...  (Though, next console cycle, I'm probably going PS4 over XB1...  Or, maybe some SteamOS-based console if they release a decent one!)

Offline

#3 2013-10-24 09:36 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,230

Re: Linux

Your distro is probably "elementary OS", a Ubuntu spin-off. "Luna" is the code name of your current version.

What I loved about Linux when I first discovered it was that you could see what was happening and how it worked, you could poke at it, look into the source, and be generally close to the system without a big blob of crappy software standing in the way. I've tried many distro's, but mostly I've used Gentoo in the early days and Arch Linux the longest, up to today (although I hate they've switched to systemd). I have customised my laptop system quite a bit: Self compiled kernel with some patches, a custom init system, self compiled Fluxbox with my own modifications, and static /dev/ with no udev/systemd. The desktop is currently running vanilla Arch, to see how that is nowadays.

I don't like Ubuntu and Fedore because they try to do too much stuff automatically, and when (not if) that fails and something breaks, it's hell fixing it. They're also very slow in booting and have all this slow and pointless desktop stuff going on (though computers got a bit faster in the meantime). What I didn't like about Debian was that it seemed to have its own way of configuring everything instead of using the software's own config system, and it also had a bit too many packages and dependencies, it always seemed to want to pull in the whole world if one bit got updated. Slackware is fine if you install everything. I didn't, and then I discovered I really like automatic dependency resolving package management.

I haven't run Windows for probably 10 years now, though I've used it now and then of course.

Offline

#4 2013-10-25 12:05 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Linux

although I hate they've switched to systemd

Ugh...  I haven't had any experience with that yet, but I just hate that they keep making drastic changes to core parts of the system which totally change how you administer things...  Sure, SysV init scripts aren't the most elegant thing in the world, but I fucking understand them, at least!  I really have no desire to learn yet another init system... *sigh*

And, I hear there's now a push to replace syslog with some "journald" bullshit, which maintains fucking binary logs!  It may even be part of systemd now, instead of a stand-alone thing you can avoid, I'm not sure...  Ugh...  Worst idea ever...  WTF is so wrong with syslog and its nice plain text logs??  They've worked very well forever, and I've never heard any complaints about them...  Changing things that have flaws and deficiencies is one thing, but just changing shit that works well for the sake of change annoys the hell out of me...

Offline

#5 2013-10-25 08:18 PM

RipRage
Member
From: England
Registered: 2010-01-06
Posts: 146

Re: Linux

i3839 wrote:

Your distro is probably "elementary OS", a Ubuntu spin-off. "Luna" is the code name of your current version.

Yeah that's it!, Sorry Rob I didn't give you much to go on there with "Luna" ;-), I think its gorgeous! Every time I have a play with linux, be it ubuntu, fedora etc, I always try to graphically make it look like what the developers have done here with elementary OS, transparent terminal, beautiful nature type wallpapers, nice clear fonts (no icons) docking bar with autohide on (keep the desktop clear of icons ;-) (although not essential)) etc. But one thing which really annoys me is that any ubuntu --> debian based system always have problems with wireless in regards to intel chips!!!! as a result im back on windows writing this now :( because i cant figure out whats wrong, I have address information from dhcp, I have an arp entry for the default gatway, ive pinged the stack and the nic with success but cannot ping the gateway, I cannot seem to resolve host-names, ive done a netstat -i and all I see is RX/TX errors!?

the driver is:

*-network                   
description: Wireless interface     
product: Centrino Wireless-N 2230     
vendor: Intel Corporation     
physical id: 0     
bus info: pci@0000:01:00.0     
logical name: wlan0     
version: c4    
serial: 60:36:dd:53:3b:6c    
width: 64 bits      
clock: 33MHz       
capabilities: bus_master cap_list ethernet physical wireless      
configuration: broadcast=yes driver=iwlwifi 
driverversion=3.2.0-51-generic firmware=18.168.6.1 
ip=192.168.1.3 latency=0 multicast=yes wireless=IEEE 802.11bgn     
resources: irq:44 
memory:f1500000-f1501fff
Kernel

Could this be a driver issue ? When I briefly used fedora the other day the wireless worked flawlessly! I was thinking of booting up the live CD for fedora and seeing what driver was being used, and perhaps porting it to elementary OS, would this work ?

Robseace wrote:

Though, next console cycle, I'm probably going PS4 over XB1...

Interested to know your thoughts on this, I still cant decide myself, I was with Sony for the playstation 2, and then jumped to the xbox 360, mind I am a bit of a game hoarder, I grab them when the prices drop and think to myself one day ill play that, but never do, just cant seem to find the time :( my kids are the only ones who get any use out of it but they are strangely fixated on this "Minecraft" game!, you have all this gaming power at your hands, yet they play the most basic looking thing I have ever seen, its fascinating! hehe :)

Offline

#6 2013-10-25 10:03 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,230

Re: Linux

Don't bother porting the driver, try upgrading your kernel, firmware and/or system first.
But if you can ping your modem you have an IP address. What's your `route -n` output
and /etc/resolv.conf content?

Rob: That's systemd in a nutshell: Maddening non-UNIX like changes all over the
place with zero upsides. And of course journald is part of systemd... Another gem:
I can't find my coredumps back because systemd hides them somewhere...

Offline

#7 2013-10-26 12:47 AM

RipRage
Member
From: England
Registered: 2010-01-06
Posts: 146

Re: Linux

i3839 wrote:

Don't bother porting the driver, try upgrading your kernel, firmware and/or system first.
But if you can ping your modem you have an IP address. What's your `route -n` output
and /etc/resolv.conf content?

Just updated the kernel and system to the latest versions, but still no joy.

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     1      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     2      0        0 wlan0

/etc/resolv.conf
nameserver 127.0.0.1

lo        no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:"RipRage"  
          Mode:Managed  Frequency:2.412 GHz  Access Point: 80:B6:86:C3:69:60   
          Bit Rate=1 Mb/s   Tx-Power=16 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=70/70  Signal level=-38 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:1  Invalid misc:57   Missed beacon:0


wlan0     Link encap:Ethernet  HWaddr 60:36:dd:53:3b:6c  
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::6236:ddff:fe53:3b6c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:37 errors:0 dropped:0 overruns:0 frame:0
          TX packets:119 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2192 (2.1 KB)  TX bytes:17531 (17.5 KB)

Kernel Interface table
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500 0      3846      0      0 0          2726      0      0      0 BMRU
lo        16436 0       680      0      0 0           680      0      0      0 LRU
wlan0      1500 0        37      0      0 0           119      0      0      0 BMRU

Ill keep trying, get there in the end I'm sure :)

Last edited by RipRage (2013-10-26 12:50 AM)

Offline

#8 2013-10-26 08:34 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,230

Re: Linux

Two problems: You got both eth0 and wlan0 with the same IP address and routes,
and you only got a 1 Mb/s link rate for your wireless. To get it working you need
to end up with a default gateway (G flag) on wlan0, not eth0. So what I guess is
that you're using the same subnet for both LAN and WLAN on your modem, which
confuses your laptop if you connect both ethernet and try to get wifi working.

So you could first try bringing eth0 down before trying to connect the wifi and see
if that works.

If the 1 Mb/s stays like that then that's probably a driver/firmware issue, or your
reception is really really bad.

The 127.0.0.1 in resolv.conf probably means you're using something like dnsmasq,
or some other DNS cacher.

But I'm just guessing.

Offline

#9 2013-10-26 02:48 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Linux

Interested to know your thoughts on this, I still cant decide myself, I was with Sony for the playstation 2, and then jumped to the xbox 360,

Same here!  Though, the reasons were purely game-related, not any proper evaluation of the hardware or anything...  GTA3 was a PS2 exclusive for a while, so I bought a PS2...  GTA4 had timed exclusive DLC available for Xbox360, so I bought an Xbox360... ;-)  GTA is one of those game series that I'm so in love with, I'm willing to do whatever is necessary to play ASAP...  Sort of like Doom and Quake used to be on the PC side: if the newest version required better hardware than I had, it was time for an upgrade... ;-)

As for PS4 vs. XB1, I was mainly just totally turned off by MS's bungled introduction of XB1...  (Plus, what a shitty name!  Xbox One, really?  That's what everyone calls the original Xbox that preceded the 360!)  Their initial ideas were just horrible: crappy DRM, Net connection always required to play even offline single-player games, no used game sales, etc...  They were eventually forced to backpedal on EVERYTHING they announced after the outraged reaction from everyone, especially once Sony seized on the opportunity by announcing how awesome the PS4 was in comparison, with none of those horrible misfeatures...  Once it was clear they were getting crushed in pre-orders by PS4, and XB1 was looking like another disaster on the order of MS Bob, they rapidly changed course...  But, too little too late for me...  Plus, PS4's hardware looks to be superior...

However, ultimately it will come down to games again for me...  I won't be buying either for a while, until something comes out that I really, really want to play on them...  At that point, if one or the other gets any special exclusives, that may be the deciding factor...

my kids are the only ones who get any use out of it but they are strangely fixated on this "Minecraft" game!, you have all this gaming power at your hands, yet they play the most basic looking thing I have ever seen, its fascinating! hehe :)

Oh, man, that's such a fucking addictive game!  Don't start playing unless you want to waste weeks of your life!  Yeah, it looks ugly and like it can't possibly be any fun, but once you start mining, and building yourself a house, and then adding various touches here and there, and oh I better put in a rail system to take me down to my mining tunnels from my house, and oh look I found a cave system to explore for the next 5 hours!  It's a major time-sink...  And, it's one where you never truly are "done" with the game because there's no end goal or anything really, so you can always think of something else to do...  It's a great game, but I just can't handle the time-suck anymore, so I try to avoid playing it... ;-)

Offline

#10 2013-10-28 05:41 PM

RipRage
Member
From: England
Registered: 2010-01-06
Posts: 146

Re: Linux

i3839 wrote:

Two problems: You got both eth0 and wlan0 with the same IP address and routes,
and you only got a 1 Mb/s link rate for your wireless. To get it working you need
to end up with a default gateway (G flag) on wlan0, not eth0. So what I guess is
that you're using the same subnet for both LAN and WLAN on your modem, which
confuses your laptop if you connect both ethernet and try to get wifi working.

Thanks for your suggestions, after wasting time messing around with drivers and configs, it turns out to be TKIP causing the issue, not exactly sure why, but i changed TKIP to AES on the router and hey presto it works!

And I didn't realize Linux was so fucking responsive!!! I click on an icon and bang its there with no delay!!! its strange booting into windows now, everything seems to lag a little bit!

Out of curiosity guys, what do you use for writing code in linux, do you use an IDE like codeblocks or geany or something ? i cant decide.. but it would be handy to be able to use something that supports C and Java (for Uni), as i would like to slowly start putting windows in the background now and eventually live without it!

I also had a look at ARCH linux, just reading the beginners installation guide was a bit overwhelming! but looks seriously fun to set up!

Robseace wrote:

GTA3 was a PS2 exclusive for a while, so I bought a PS2...  GTA4 had timed exclusive DLC available for Xbox360, so I bought an Xbox360... ;-)  GTA is one of those game series that I'm so in love with, I'm willing to do whatever is necessary to play ASAP...

I have always been a fan too! Shortly after purchasing GTA4, my xbox suffered the famous red-ring of death, i decided to get rid of it and sell off my games, but then six months later i bought another console, the new shape model with the kinnect (since apparently they fixed the issue)... I here GTA5 is really good? (i am waiting for the price to drop here before i get it ;-) )

I was mainly just totally turned off by MS's bungled introduction of XB1...  (Plus, what a shitty name!  Xbox One, really?  That's what everyone calls the original Xbox that preceded the 360!)  Their initial ideas were just horrible: crappy DRM, Net connection always required to play even offline single-player games, no used game sales, etc...

Totally agree, that's exactly what has put me off buying one!!! the no used game sales is just a terrible idea! they can't be allowed to do that surely! and the net connection is ridiculous, yeah i know its 2013 and the internet is more popular than ever! but to make it a requirement is just bloody stupid!

Oh, man, that's such a fucking addictive game!  Don't start playing unless you want to waste weeks of your life!

HAHA! To late! I thought right what is all this fuss about, so my son and I started playing last week and I just cannot put it down!!! we found this really lovely lake and built a house in the mountain beside it, and we have been going into caves mining and all sorts of shit! hehe what an addictive game!!!

Offline

#11 2013-10-28 08:24 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Linux

Out of curiosity guys, what do you use for writing code in linux, do you use an IDE like codeblocks or geany or something ?

I just use vim...  I can't stand fancy IDEs and crap; they just get in my way...  Hell, I don't even use vim's built-in syntax hilighting while coding!  (It's useful for reading code, but I can't stand distractions like that while WRITING code...)

I here GTA5 is really good? (i am waiting for the price to drop here before i get it ;-) )

Yep, best of the series so far, IMHO...  I just finished it the other week (I pretty much only get to play on weekends, so I don't progress through as fast as most people), and spent this last weekend doing various side missions and stuff I didn't yet get to...  I've briefly tried the online multiplayer, but I just generally am burned out on multiplayer games these days...  I feel like I'm too old to keep up with the youngsters playing online... ;-)  But, I might give it more of a try next weekend...  But, I really, really hope they release single player DLC relatively soon!  I really want to do more big heists with the three main player characters...  Planning those, setting them up, and carrying them out are fun as hell...  In the meantime, I may go back and replay some of the heists from the main game, trying different tactics and things...  (They usually let you choose from 2 or more different approaches to each heist, and then you get to pick a crew of NPCs with various different skills to help you out, then depending on the approach chosen, you have to gather various needed supplies, then carry it out...)

hehe what an addictive game!!!

Oh, man, it really is...  I have no idea why I felt so compelled to spend months gathering materials and building my obsidian mountain palace, and miles and miles of minecart track wending its way through the underground, but I did!  Every once in a while when I run out of other stuff to play, I think about maybe going back to it, but I know that if I do, I'll be sucked back in again...

Offline

#12 2013-10-29 10:12 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,230

Re: Linux

I use NEdit and Vim. I really like NEdit's behaviour. I can't stand fancy IDE's and crap either.

I've always been a PC gamer, but I stopped playing games when I fully switched to Linux. They take too much time anyway. Since then I've only played the games a friend told me to try out. I'm glad he did, otherwise I wouldn't have played Portal.

Offline

#13 2013-10-29 12:23 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Linux

I'm glad he did, otherwise I wouldn't have played Portal.

One of the best games of all time, IMHO, along with its sequel...  And, thanks to Valve's big Linux push recently, it's now available on Linux, too!  Hopefully, they'll get Portal 2 ported soon as well...  At which point, I may have no choice but to buy a faster machine to install it on... ;-)  I've already played both games on Xbox, but just the idea of being able to play them on Linux is appealing...  When id basically dumped Linux as a viable gaming platform, I thought it was mostly doomed, but now that Valve has come charging in, it may have a shot yet!

Offline

#14 2013-10-31 08:36 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,230

Re: Linux

Valve should have started with Linux support ten years ago. Still great that they finally do start supporting Linux though. Pity about the abysmal driver support and that OpenGL didn't get its act together. Oh well.

Offline

#15 2013-10-31 12:23 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Linux

Yeah, if Valve had come on board when both id and Epic were still enthusiastic about supporting Linux, things would likely be a lot different today...  The only reason they're doing it now is because they hate Win8 and the walled-garden app store approach MS is heading towards, which they think will ultimately drive Steam out of business...  But, whatever their reasons, I'm glad to finally have them on board...  It's just a shame that it's come so late that all the other big name game companies have essentially long since abandoned ship... ;-/  Maybe they'll be coaxed back aboard now that Valve is here, though...  Both id and Epic seem more focused on consoles than PC these days anyway, so I don't know...

As for drivers, one good side-effect of Valve getting involved has been that Nvidia has pledged to help improve the open source drivers...  Well, one can only speculate there's some connection there, since they've steadfastly refused to help in the past and only have done so now once Valve announced SteamOS...  Of course, if you don't mind running proprietary binary modules, Nvidia's drivers were always decent anyway...  But, if you'll only run open source drivers, this is great news...

Offline

#16 2013-11-05 01:05 PM

RipRage
Member
From: England
Registered: 2010-01-06
Posts: 146

Re: Linux

Portal, now that is one hell of a game, I also loved half life 2! Rob, have you played Sleeping Dogs? It's kinda of like GTA with Bruce Lee ;-)

Guys what do you think of a network diagnosis / autofix tool for linux? After solving my wireless issue It's kind of inspired me to write something cool and sophisticated to auto diagnose and fix network issues... But with linux being rarther robust compared so windows, I'm not sure if it will be needed or would require any use...

I have also been reading advance programming in the unix environment by Stevens :), I didn't realise that errno does not get reset between failed and succeeded system calls! That is strangely useful, on windows for example, socket() could fail setting GetLastError() then closessocket() would reset it back to 0! Meaning you would have to save and reset the error value when cleaning up and returning in a cover function

Last edited by RipRage (2013-11-05 01:10 PM)

Offline

#17 2013-11-05 02:09 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Linux

Portal, now that is one hell of a game,

I love both it and its sequel...  I would kill for another sequel or even just extensive DLC with more levels to complete!  That's one good thing that should come with a Linux/SteamOS native version, hopefully: access to all the user-created levels to play through...  Right now, I have only played them on Xbox360, and there you are unable to play any user-created levels at all...  I've played through both games probably a dozen times each now, including the small handful of extra challenge levels Valve released for the first Portal (for the second one, they lamed out and just enacted challenges on the stock P2 levels, rather than creating entirely new levels)...  I keep desperately hoping for either new levels or to suffer some kind of horrible memory loss so that playing through the old levels feels new again... ;-)

I also loved half life 2!

I actually still haven't yet played that, strangely enough!  I own The Orange Box for X360, which contains it along with all the HL2 episodes (and along with the first Portal, which is the sole reason I bought it), but just never have bothered to play it...  I was never all that in love with the first Half Life the way most seemed to be at the time, so I kind of figured I wouldn't be all that into HL2 either...  But, I should still probably give it a try someday, if I ever find the time...

Rob, have you played Sleeping Dogs? It's kinda of like GTA with Bruce Lee ;-)

Oh yeah, that game was great!  At first, I thought I was going to hate it, because of the focus on hand-to-hand combat involving lots of crazy button-pressing combos...  I absolutely loathe those sort of fighting games where you have to memorize a million different combinations of button-presses...  But, it didn't take long for it to grow on me, and you really only needed to know a small handful of good moves to get by...  It ended up being really fun...

Another open world sandbox style game series I recently discovered is Assassin's Creed...  I had heard about it for a while, but just didn't pay much attention...  Then, a while back Microsoft was giving away AC2 for free to anyone with an Xbox Live Gold membership, so I said what the hell and downloaded it to try out...  I still haven't yet finished it, because I was side-tracked by the releases of Saints Row 4 and GTA5, but it's one I definitely want to get back to...  Similarly, I started out thinking I was going to hate it, because all the initial stuff you do when starting the game was lame and boring and no fun at all...  But, then it takes you back to Renaissance era Italy and finally opens up the gameplay to full sandbox mode, and shit starts getting really fun!  I love the parkour/free-running abilities to climb just about anything and run along the roofs of buildings and stuff...  I spent a whole lot of time just ignoring all the missions and finding and climbing the tall watchtowers scattered all over the place...

Guys what do you think of a network diagnosis / autofix tool for linux?

If you can write code to replace a human network/systems administrator, you could make a mint! ;-)

I didn't realise that errno does not get reset between failed and succeeded system calls! That is strangely useful, on windows for example, socket() could fail setting GetLastError() then closessocket() would reset it back to 0! Meaning you would have to save and reset the error value when cleaning up and returning in a cover function

Yeah, but it's the sort of thing you still can't really rely on if you absolutely need the original errno value, because if your close() fails for some reason, it WILL still trash errno, and you'll then be reporting the error from the close() rather than from whatever other call you wanted, which can then make debugging the real issue a real pain...  So, lots of Unix code will still do the save/restore errno trick too...

Offline

#18 2013-11-11 01:04 PM

RipRage
Member
From: England
Registered: 2010-01-06
Posts: 146

Re: Linux

RobSeace wrote:

I actually still haven't yet played that, strangely enough!  I own The Orange Box for X360, which contains it along with all the HL2 episodes (and along with the first Portal, which is the sole reason I bought it), but just never have bothered to play it...  I was never all that in love with the first Half Life

I must admit I have never played the first one, but the second was awesome! IMHO I think its one of the best first-person shooters I have ever played, also the graphics where gorgeous (on the PC when it was first release), Orange Box is something I really need to re-add to my collection, another classic I sold on when my old console broke.

Another open world sandbox style game series I recently discovered is Assassin's Creed...

Yes it's an awesome game!

I had heard about it for a while, but just didn't pay much attention...  Then, a while back Microsoft was giving away AC2 for free to anyone with an Xbox Live Gold membership

Damn missed out on that :(

But, then it takes you back to Renaissance era Italy and finally opens up the gameplay to full sandbox mode, and shit starts getting really fun!

haha yes it does!! its incredible! I also need to purchase that again, but now I'm not sure which one to get, I think were on number three or four now? Out of interest Rob, are you much of a COD fan ? I must admit I'm not particularly keen (properly due to the on-line play where I continuously get my ass handed to me within nano seconds ;-) Some people are just insanely good at that game) However, I do like the black ops editions, we play that a lot at home, only because in local mode you can do multi-player against 'Bots' which gives you a chance to enjoy the multi-player aspect without getting annihilated! ;-)

Guys, a couple of questions if I may, just to clear things up, the first is structure alignment and protocol headers in regards to portability, I have always created and used serialization functions for packing and unpacking structure elements into and out of a byte array which I believe is the correct thing to do ?, recently I have been reading various bits of source code (the uIP stack, linux kernel, as well as libcap stuff), where I often see code where a structure is simply laid over a byte array, now I know that's only safe to do if you can guarantee that...

sizeof(struct arp) = 28 bytes

To ensure this, I would expect to see for example

__attribute__((__packed__ ))

Which I have only really seen in the network stack of the linux kernel, so my question is how would you guys handle this ? would you use "__attribute__((__packed__ ))" is this portable between unix based systems? resulting in code that does say...

struct arp = (struct arp *) bufptr;

instead of say unpacking each element

unpack_bytes(buf, len, "%c%c", &arp->arp_hard_size, &arp->arp_proto_size, blah blah)

Second question is guys, Is there an API or system calls for controlling a network interface, I.e putting the interface down/up, setting IP address etc, or would you have to write everything to a buffer and call system() ?

Edit: I will have another read up on ioctl() If i remember rightly I think you can add / delete routes and various other bits and pieces Ill see if it supports setting address information...

Last edited by RipRage (2013-11-11 02:48 PM)

Offline

#19 2013-11-11 04:52 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Linux

I think were on number three or four now?

They just recently released AC4, which apparently sees you in the role of a pirate this time...  Could be interesting, but I'm not sure if I'd like it as much...  In any case, I'm not going to pick it up for a while, since I wouldn't get around to playing it for quite some time...  I want to finish up AC2 first, then maybe check out AC3...  I think there are some non-numbered sequels (or maybe just DLC?) in there, as well...

Out of interest Rob, are you much of a COD fan ?

No, I don't think I've ever played any of them at all...  They don't look like my style of FPS...  I'm much more into the actiony/arcadey Quake-style FPS, not realistic military shooters...  I hate Halo as well...  I tried one of those once, figuring it looked like it might be a fun Quake-style FPS, but it was just boring and lame, I thought...

only because in local mode you can do multi-player against 'Bots' which gives you a chance to enjoy the multi-player aspect without getting annihilated! ;-)

That's pretty much the only way I can play any competative FPS these days: against bots...  I used to love playing against other players back in the Q1, Q2, Q3A days, but at some point my skills just atrophied, and now it's just embarassing to play against humans... ;-)  Every once in a while, I get the urge to fire up some Q3TA capture the flag against bots, though...

Which I have only really seen in the network stack of the linux kernel, so my question is how would you guys handle this ? would you use "__attribute__((__packed__ ))" is this portable between unix based systems?

That's a GCCism, so it should be portable to anywhere where GCC is your compiler...  But, most compilers have a way of doing something similar...

The reason you probably didn't see it used some places is that those structs were all naturally aligned and pad-free...  If you are careful to use fixed-size types (eg: int32_t, int16_t, etc.), or just know that the types your are using are effectively fixed-size on all platforms you care about, then you can often arrange the layout of the struct so that no padding will be inserted by the compiler, without the need to specify it as packed...  (Lots of times, you'll see the programmer adds their own explicit padding fields to the struct themselves, where padding can't otherwise be avoided...)  The only time you really need to explicitly pack it is when the compiler would otherwise want to insert padding between fields...  And, in general, it's better to naturally align the struct fields by hand and insert manual padding if necessary, rather than pack the struct...  Because, field accesses to a packed struct may be less efficient, if they are no longer aligned properly...

But, yeah, as long as you have a stable, aligned struct with fixed-size fields, there should be no problem with just directly casting the struct to/from a buffer, or directly passing a pointer to one to send()/recv(), or whatever...  The only problem to really worry about is the endianness of any integer fields within the struct...  But, if you always swap them to network order for sending, then back to host order after receipt, things should be fine...  (Or, if you know you're only ever going to be sending between machines of identical endianness, you can be lazy and leave them in host order always...)

Second question is guys, Is there an API or system calls for controlling a network interface, I.e putting the interface down/up, setting IP address etc, or would you have to write everything to a buffer and call system() ?

Edit: I will have another read up on ioctl() If i remember rightly I think you can add / delete routes and various other bits and pieces Ill see if it supports setting address information...

Yeah, there's all the SIOC* ioctl()'s...  Yes, you can set IP with SIOCSIFADDR...  It's a bit ugly, in that the interface is ancient and works off simple sockaddr structs, which means it's not really compatible with IPv6...  There are kluges to get around it (read the source for "ifconfig" or similar), but it's ugly...

For just obtaining a list of interfaces and associated info, getifaddrs() is a much nicer interface to use...  But, if you need to modify the interface info, you'll probably have to deal with the ioctl() calls...

For modifying route info, there's ioctl(SIOC*RT), but I've never dealt with them before...  There's also AF_NETLINK/NETLINK_ROUTE sockets...  But, that's a Linux specific thing...

Offline

#20 2013-11-14 12:33 PM

RipRage
Member
From: England
Registered: 2010-01-06
Posts: 146

Re: Linux

Thanks for making that clear Rob!

Robseace wrote:

There's also AF_NETLINK/NETLINK_ROUTE sockets...  But, that's a Linux specific thing...

Huh, I've never heard of AF_NETLINK sockets before, I don't think there mentioned in Stevens book (3rd edition), are they a fairly new thing ? It seems that there preferred over ioctl() for acquiring network information, pretty cool how they are used like an ordinary socket but for sending and receiving messages between kernel and user space...

Offline

#21 2013-11-14 01:24 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Linux

Huh, I've never heard of AF_NETLINK sockets before, I don't think there mentioned in Stevens book (3rd edition), are they a fairly new thing ?

No, they've been around quite some time, but UNP wouldn't be likely to cover them, because they're a Linux-specific feature rather than a standard Unix thing...

Quite some time ago, I briefly messed around with them, but didn't do much with them...  The documentation on them is pretty horribly lacking...  There's some "libnl" cover library that's supposed to make using them more practical, but at the time at least, the documentation on that was equally horrible...

I did really like the concept in theory, though...

Offline

#22 2013-11-23 01:42 AM

RipRage
Member
From: England
Registered: 2010-01-06
Posts: 146

Re: Linux

Rob, I bought sleeping dogs last week and I haven't been able to put it down since!!! (I only played the demo beforehand) and man this game is intense, there's a few issues with the vehicles and bits and pieces here and there, not as 'fluid' as GTA but the combat system sure makes up for it, is freaking awesome! (fairly similar to AC if I remember rightly) I just love how the counter attacks work,  and how you interactive with the surroundings (I threw this one guy into a giant fish tank! ;-) )

Also been looking into the new consoles, have you heard of a game called "Destiny"? it may just be your thing, sci-fi FPS, but it seems to have some RPG aspects to it, the graphics look insane... on that note, are you much of a mass effect fan? I only played the first and was not overly keen, but I hear good things about 2 and 3,

While I'm here guys, can I just ask what's an appropriate way of programmatically executing another program? On windows I believe this is called hooking?

Also guys, I can honestly say, that I haven't booted into windows since I started this thread, I really do wish I felt comfortable with Linux sooner, I have always been interested, but have always gone back to windows for some reason or another, but I have to admit, I really love it, its just so quick and responsive, (in general, and of course the network side of things) I also found "codelite" this lovely lightweight IDE (i know you guys don't think much of IDE's but once you have used M$ vc++ for a while you kind of get used to it and anything else feels foreign) but this fantastic! and its so enjoyable writing in C on linux (its native language) none of this CamelCase and functions with a billion arguments (just my opinion, I don't want to offend anyone) I really hope to progress well under Linux, I have download various open source code and have been studying them slowly, the kernel (although one tough mother to understand) ifconfig/iwconfig, ISC's dhclient and loads of other bits of pieces...

Last edited by RipRage (2013-11-23 01:45 AM)

Offline

#23 2013-11-23 04:52 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Linux

I just love how the counter attacks work,  and how you interactive with the surroundings (I threw this one guy into a giant fish tank! ;-) )

Oh yeah, the attacks involving environment elements were always great...  And, I liked the various skill trees where you could aquire different skills of your choice, like being able to break into cars stealthily without setting off alarms...

Also been looking into the new consoles, have you heard of a game called "Destiny"?

I think I had heard some vague mentions of it, but didn't pay any attention to it...  It's coming from the makers of Halo, and I hate those games, so I'm not expecting it to be my thing...  Plus, it sounds like it's going to be sort of MMO like, in that you're always online interacting with other players, and I generally don't enjoy multiplayer gaming much at all these days...  (Especially on consoles, where most people seem to be obnoxious teens just being assholes...)

on that note, are you much of a mass effect fan?

I never played any of them...  I always thought they sounded interesting, but just never got around to checking any of them out...

While I'm here guys, can I just ask what's an appropriate way of programmatically executing another program? On windows I believe this is called hooking?

I'm not sure exactly what you mean...  Just executing another program as a separate stand-alone process?  For that, there's fork() + exec*()...  (Or, some cover thereof like posix_spawn*() or system() or whatever...)  Or, if you want your program to just transform into another program, skip the fork() and just do exec*()...

If you mean just calling some functions from another program and have them run in the context of your current process, for that you typically want to just have those sharable functions defined in a shared library which all users can link in either at compile time, or dynamically at run time via dlopen() and then use dlsym() to lookup functions by name...  You could theoretically mmap() or read in the contents of another program and poke around in it (probably using the <elf.h> structures and macros) to find function code to call too, if you really wanted, but it's ugly...

Offline

#24 2013-11-24 05:11 PM

RipRage
Member
From: England
Registered: 2010-01-06
Posts: 146

Re: Linux

I suppose system() will do, what I want to achieve is execute the dhclient, I.e "sudo dhclient -4 wlan0" in an event  where an interface for whatever reason is connect to a gateway / AP but hasn't been assigned an IP address, I suppose then I could call getifaddrs() again to check for an IP.  I would have a go at implementing a lightweight version of DHCP myself but I've read mixed bits and pieces saying that you cannot bind to an interface without an IP so some raw socket trickery is used ? Although saying that, I had no trouble releasing the IP set to on my wlan0 interface and passing 255.255.255.255 to getaddrinfo(), and binding with setsockopt(SO_BROADCAST)...

Offline

#25 2013-11-25 01:07 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Linux

but I've read mixed bits and pieces saying that you cannot bind to an interface without an IP so some raw socket trickery is used ?

I thought that's what SO_BINDTODEVICE was created for...  It lets you bind via interface name rather than IP...  But, I've honestly never used it for anything, so I'm not really sure if/how it works...

passing 255.255.255.255 to getaddrinfo()

Waste of a getaddrinfo() call...  There's already a predefined macro for the limited broadcast address: INADDR_BROADCAST...

Offline

Board footer

Powered by FluxBB