How do I run my application as superuser from Eclipse?

You can follow these steps to compile/debug applications as superuser. Rename your java-application sudo mv /usr/lib/jvm/java-6-openjdk/jre/bin/java /usr/lib/jvm/java-6-openjdk/jre/bin/java.ori Create following script and store it as /usr/lib/jvm/java-6-openjdk/jre/bin/java #!/bin/bash # file: /usr/lib/jvm/java-6-openjdk/jre/bin/java # descr: Starter for jdk. Runs jdk as root when # cmd-line-arg “–run-as-root” is specified. # jre=”/usr/lib/jvm/java-6-openjdk/jre/bin/java.ori” run_as_root=false args= # Filter command-line argument for arg in … Read more

close() is not closing socket properly

Here is some code I’ve used on many Unix-like systems (e.g SunOS 4, SGI IRIX, HPUX 10.20, CentOS 5, Cygwin) to close a socket: int getSO_ERROR(int fd) { int err = 1; socklen_t len = sizeof err; if (-1 == getsockopt(fd, SOL_SOCKET, SO_ERROR, (char *)&err, &len)) FatalError(“getSO_ERROR”); if (err) errno = err; // set errno … Read more

Does the port change when a server accepts a TCP connection?

The new socket is an application-level concept introduced because each established connection needs a unique file descriptor (also distinct from the listening file descriptor), which maps to, but isn’t the same as, a TCP session. The session itself is identified by the combination of source and destination address and port. The source (client) port is … Read more

How to share semaphores between processes using shared memory

It’s easy to share named POSIX semaphores Choose a name for your semaphore #define SNAME “/mysem” Use sem_open with O_CREAT in the process that creates them sem_t *sem = sem_open(SNAME, O_CREAT, 0644, 3); /* Initial value is 3. */ Open semaphores in the other processes sem_t *sem = sem_open(SEM_NAME, 0); /* Open a preexisting semaphore. … Read more

why do we use 10.0.2.2 to connect to local web server instead of using computer ip address in android client

Network Address Space Each instance of the emulator runs behind a virtual router/firewall service that isolates it from your development machine’s network interfaces and settings and from the internet. An emulated device can not see your development machine or other emulator instances on the network. Instead, it sees only that it is connected through Ethernet … Read more