Connect: Socket operation on non-socket

I see the problem. It’s this line: The == operator has precedence over the = operator. Look at the way you have the parentheses structured on that expression a bit more carefully to see what I mean. sockfd is getting initialize to “0” as a result of being assigned a boolean expression (socket(…) == -1). … Read more

How do I grep recursively?

The first parameter represents the regular expression to search for, while the second one represents the directory that should be searched. In this case, . means the current directory. Note: This works for GNU grep, and on some platforms like Solaris you must specifically use GNU grep as opposed to legacy implementation. For Solaris this is the ggrep command.

What are .a and .so files?

Archive libraries (.a) are statically linked i.e when you compile your program with -c option in gcc. So, if there’s any change in library, you need to compile and build your code again. The advantage of .so (shared object) over .a library is that they are linked during the runtime i.e. after creation of your … Read more

Display exact matches only with grep

ou need a more specific expression. Try grep ” OK$” or grep “[0-9]* OK”. You want to choose a pattern that matches what you want, but won’t match what you don’t want. That pattern will depend upon what your whole file contents might look like. You can also do: grep -w “OK” which will only match a whole word “OK”, … Read more

grep –ignore-case –only

This is a known bug on the initial 2.5.1, and has been fixed in early 2007 (Redhat 2.5.1-5) according to the bug reports. Unfortunately Apple is still using 2.5.1 even on Mac OS X 10.7.2. You could get a newer version via Homebrew (3.0) or MacPorts (2.26) or fink (3.0-1). Edit: Apparently it has been fixed on OS X 10.11 (or maybe earlier), even … Read more

In the shell, what does ” 2>&1 ” mean?

File descriptor 1 is the standard output (stdout).File descriptor 2 is the standard error (stderr). Here is one way to remember this construct (although it is not entirely accurate): at first, 2>1 may look like a good way to redirect stderr to stdout. However, it will actually be interpreted as “redirect stderr to a file named 1“. & indicates that what follows and precedes is … Read more

What is the meaning of *nix?

*nix just means operating systems that are like the old workhorse Unix. Some examples include Linux, FreeBSD, and Mac OS X (its kernel, Darwin, is based on BSD). The main relation between *nix and Ruby is just a pragmatic one; most Ruby developers seem to prefer to work on Unix-like OSes (typically Linux or Mac … Read more