Search Results

Search found 29 results on 2 pages for 'shadyabhi'.

Page 1/2 | 1 2  | Next Page >

  • Routing data through VPN in linux

    - by Shadyabhi
    I think its a silly question but still here it goes.. Terminal Output: eth0 Link encap:Ethernet HWaddr 00:1c:c0:37:5e:25 inet addr:10.100.98.51 Bcast:10.100.98.255 Mask:255.255.255.0 inet6 addr: fe80::21c:c0ff:fe37:5e25/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:29677 errors:0 dropped:0 overruns:0 frame:0 TX packets:5209 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:3179007 (3.1 MB) TX bytes:610142 (610.1 KB) Memory:e0380000-e03a0000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:76 errors:0 dropped:0 overruns:0 frame:0 TX packets:76 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:9555 (9.5 KB) TX bytes:9555 (9.5 KB) vpn_0 Link encap:Ethernet HWaddr 00:ac:39:95:a1:16 inet6 addr: fe80::2ac:39ff:fe95:a116/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1786 errors:0 dropped:0 overruns:0 frame:0 TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:500 RX bytes:128597 (128.5 KB) TX bytes:468 (468.0 B) Actually, I followed this tutorial to setup the PacketiX VPN on ubuntu. Now, how do I actually use this VPN? Terminal Output: shadyabhi@shadyabhi-desktop:~$ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.100.98.0 * 255.255.255.0 U 1 0 0 eth0 link-local * 255.255.0.0 U 1000 0 0 eth0 default 10.100.98.4 0.0.0.0 UG 0 0 0 eth0 shadyabhi@shadyabhi-desktop:~$ As told in tutorial, if I do route del default route add default dev vpn_0 I am not able to surf the internet. And I get the route command output as: root@shadyabhi-desktop:/home/shadyabhi# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.100.98.0 * 255.255.255.0 U 1 0 0 eth0 link-local * 255.255.0.0 U 1000 0 0 eth0 default * 0.0.0.0 U 0 0 0 vpn_0 root@shadyabhi-desktop:/home/shadyabhi# I know I am not able to route the traffic properly. How do i do that?

    Read the article

  • "eject" command not working..

    - by shadyabhi
    shadyabhi@shadyabhi-desktop:~$ eject -v eject: using default device `cdrom' eject: device name is `cdrom' eject: expanded name is `/media/cdrom' eject: `/media/cdrom' is a link to `/media/cdrom0' eject: `/media/cdrom0' is not mounted eject: `/media/cdrom0' is not a mount point eject: tried to use `/media/cdrom0' as device name but it is no block device eject: unable to find or open device for: `cdrom' shadyabhi@shadyabhi-desktop:~$ The tray doesnt open.. How do I open tray using command line?

    Read the article

  • Same memory space being allocated again & again while using malloc()

    - by shadyabhi
    In each loop iteration, variable j is declared again and again. Then why is its address remaining same? Shouldn't it be given some random address each time? Is this compiler dependent? #include<stdio.h> #include<malloc.h> int main() { int i=3; while (i--) { int j; printf("%p\n", &j); } return 0; } Testrun:- shadyabhi@shadyabhi-desktop:~/c$ gcc test.c shadyabhi@shadyabhi-desktop:~/c$ ./a.out 0x7fffc0b8e138 0x7fffc0b8e138 0x7fffc0b8e138 shadyabhi@shadyabhi-desktop:~/c$

    Read the article

  • Same memory space being allocated again & again

    - by shadyabhi
    In each loop iteration, variable j is declared again and again. Then why is its address remaining same? Shouldn't it be given some random address each time? Is this compiler dependent? #include<stdio.h> #include<malloc.h> int main() { int i=3; while (i--) { int j; printf("%p\n", &j); } return 0; } Testrun:- shadyabhi@shadyabhi-desktop:~/c$ gcc test.c shadyabhi@shadyabhi-desktop:~/c$ ./a.out 0x7fffc0b8e138 0x7fffc0b8e138 0x7fffc0b8e138 shadyabhi@shadyabhi-desktop:~/c$

    Read the article

  • Why is sys+user > real in "time command"?

    - by shadyabhi
    I have a program that uses pthread library to do the matrix multiplication of 500x500 matrix. Each thread calculates 50 rows of the matrix. When I run tiem command:- shadyabhi@shadyabhi-desktop:~$ time ./a.out real 0m0.383s user 0m0.810s sys 0m0.000s shadyabhi@shadyabhi-desktop:~$ How come sys+user is greater than real time?

    Read the article

  • Disable MOUSE wakeup when doing suspend on UBUNTU

    - by Shadyabhi
    When I do SUSPEND on ubuntu, in order to wake up, i can just move the mouse and the computer will wake up. But, I dont want that the computer is waked up when I move my mouse. How can I do that? My /proc/acpi/wakeup file:- shadyabhi@shadyabhi-desktop:~$ cat /proc/acpi/wakeup Device S-state Status Sysfs node SLPB S4 *enabled P32 S4 disabled pci:0000:00:1e.0 UAR1 S4 disabled pnp:00:09 ILAN S4 disabled pci:0000:00:19.0 PEGP S4 disabled PEX0 S4 disabled pci:0000:00:1c.0 PEX1 S4 disabled pci:0000:00:1c.1 PEX2 S4 disabled pci:0000:00:1c.2 PEX3 S4 disabled pci:0000:00:1c.3 PEX4 S4 disabled pci:0000:00:1c.4 PEX5 S4 disabled UHC1 S3 disabled pci:0000:00:1d.0 UHC2 S3 disabled pci:0000:00:1d.1 UHC3 S3 disabled pci:0000:00:1d.2 UHC4 S3 disabled EHCI S3 disabled pci:0000:00:1d.7 EHC2 S3 disabled pci:0000:00:1a.7 UH42 S3 disabled pci:0000:00:1a.0 UHC5 S3 disabled pci:0000:00:1a.1 UHC6 S3 disabled pci:0000:00:1a.2 AZAL S3 disabled pci:0000:00:1b.0 shadyabhi@shadyabhi-desktop:~$

    Read the article

  • write system call to file desciptor ZERO

    - by shadyabhi
    int main ( ) { char C[] = "Hello World"; write(0,C,sizeof(C)); return 0; } In the above program, I am writing to File descriptor ZERO which I suppose by default is STDIN.. Then why I am I getting output at STDOUT? shadyabhi@shadyabhi-desktop:~$ ./a.out Hello Worldshadyabhi@shadyabhi-desktop:~$

    Read the article

  • Setting minimum size limit for a window in java swing

    - by shadyabhi
    I have a JFrame which has 3 JPanels in GridBagLayout.. Now, when I minimize a windows, after a certain limit, the third JPanel tends to disappear. I tried setting minimizing size of JFrame using setMinimumSize(new Dimension(int,int)) but no success. The windows can still be minimized. So, I actually want to make a threshhold, that my window cannot be minimized after a certain limit. How can I do so? Code:- import java.awt.Dimension; import javax.swing.JFrame; public class JFrameExample { public static void main(String[] args) { JFrame frame = new JFrame("Hello World"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(400, 400)); frame.setVisible(true); } } Also: shadyabhi@shadyabhi-desktop:~/java$ java --showversion java version "1.5.0" gij (GNU libgcj) version 4.4.1 Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Usage: gij [OPTION] ... CLASS [ARGS] ... to invoke CLASS.main, or gij -jar [OPTION] ... JARFILE [ARGS] ... to execute a jar file Try `gij --help' for more information. shadyabhi@shadyabhi-desktop:~/java$ Gives me output like

    Read the article

  • Sharing a modem INTERNET on LAN

    - by Shadyabhi
    My computer is already connected to a 100Mbps LAN. I can use wvdial to connect to internet using a modem when I have my LAN disconnected. Now, I want to share this modem internet to one of the ip address available on LAN say 10.100.99.56.. First of all, can it be done? How do I go about doing that?

    Read the article

  • yum not able to install a package

    - by shadyabhi
    [root@mypc yum.repos.d]# yum search perl-Locale-gettext Loaded plugins: dellsysid, fastestmirror Repository tmz-puppet is listed more than once in the configuration Loading mirror speeds from cached hostfile * atomic: www6.atomicorp.com * base: mirror.trouble-free.net * epel: mirrors.tummy.com * extras: eq-centosrepo.hopto.org * rpmforge: mirror.hmc.edu * updates: mirror.team-cymru.org =================================================================== N/S Matched: perl-Locale-gettext ==================================================================== perl-Locale-gettext.x86_64 : Internationalization for Perl Name and summary matches only, use "search all" for everything. [root@mypc yum.repos.d] And [root@mypc yum.repos.d]# yum install perl-Locale-gettext Loaded plugins: dellsysid, fastestmirror Repository tmz-puppet is listed more than once in the configuration Loading mirror speeds from cached hostfile * atomic: mir01.syntis.net * base: mirrors.gigenet.com * epel: mirror.us.leaseweb.net * extras: centos.mirror.lstn.net * rpmforge: mirror.hmc.edu * updates: centos.mirror.choopa.net Setting up Install Process Nothing to do [root@mypc yum.repos.d]# What is going wrong here?

    Read the article

  • Webcam error (libv4lconvert) while capturing VIDEO

    - by shadyabhi
    I get the following when I capture images using my web-cam.. libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff ...(same error repeating) ... I also had issue that my camera was not getting detected in ubuntu. So, in order to run an application that uses the webcam, I have to run a command like LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so ./6dofhand Whats causing these errors?

    Read the article

  • Packets being dropped by iptables

    - by Shadyabhi
    I am trying to create a Software Access Point in linux. I followed the blog here. Steps I performed: Started dhcp server on wlan0. Properly configured hostapd.conf Enabled packet forwarding & masquerading. Two commands executed regarding iptables: iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE iptables --append FORWARD --in-interface wlan0 -j ACCEPT I enabled logging on iptables & I get this in everything.log Jun 29 19:42:03 MBP-archlinux kernel: [10480.180356] IN=eth0 OUT=wlan0 MAC=c8:bc:c8:9b:c4:3c:00:13:80:40:cd:80:08:00 SRC=195.143.92.150 DST=10.0.0.3 LEN=44 TOS=0x00 PREC=0x00 TTL=52 ID=38025 PROTO=TCP SPT=80 DPT=53570 WINDOW=46185 RES=0x00 ACK URGP=0 Jun 29 19:42:03 MBP-archlinux kernel: [10480.389102] IN=eth0 OUT=wlan0 MAC=c8:bc:c8:9b:c4:3c:00:13:80:40:cd:80:08:00 SRC=195.143.92.150 DST=10.0.0.3 LEN=308 TOS=0x00 PREC=0x00 TTL=52 ID=14732 PROTO=TCP SPT=80 DPT=53570 WINDOW=46185 RES=0x00 ACK PSH URGP=0 Jun 29 19:42:03 MBP-archlinux kernel: [10480.389710] IN=eth0 OUT=wlan0 MAC=c8:bc:c8:9b:c4:3c:00:13:80:40:cd:80:08:00 SRC=195.143.92.150 DST=10.0.0.3 LEN=44 TOS=0x00 PREC=0x00 TTL=52 ID=14988 PROTO=TCP SPT=80 DPT=53570 WINDOW=46185 RES=0x00 ACK FIN URGP=0 Jun 29 19:42:03 MBP-archlinux kernel: [10480.621118] IN=eth0 OUT=wlan0 MAC=c8:bc:c8:9b:c4:3c:00:13:80:40:cd:80:08:00 SRC=195.143.92.150 DST=10.0.0.3 LEN=44 TOS=0x00 PREC=0x00 TTL=52 ID=63378 PROTO=TCP SPT=80 DPT=53570 WINDOW=46185 RES=0x00 ACK FIN URGP=0 I have almost no knowledge of iptables, all I did was through googling. So, can anyone help me in making me understand what wrong is happening here? I have tried running tcpdump on wlan0 & http packets are being sent from wlan0.

    Read the article

  • Alternative of procman in linux

    - by shadyabhi
    I want a program which gives all information relating to a currently running process. In Windows, there is procman . Whats the alternative in LINUX? Do i have to use tools like strace etc seperately, or there is one program that does all. Do share if you know of a nice software.

    Read the article

  • logrotate deletes all maillogs older than one day

    - by shadyabhi
    I see only two files maillog and maillog.1 in /var/log. grepping for maillog in logrotate.d directory gives three files that have a mention of maillog. syslog /var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron { #/var/log/messages /var/log/secure /var/log/spooler /var/log/boot.log /var/log/cron { daily sharedscripts postrotate /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true /bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true endscript } syslog-ng /var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron /var/log/kern.log /var/log/kern { sharedscripts postrotate /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true /bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true endscript } and maillog. /var/log/maillog { daily compress # rotate 365 rotate 14 sharedscripts postrotate /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true /bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true endscript } I am new to logrotate so may be I am missing something obvious. What can be the issue? The setup was already done when I started managing the server so I don't also know as do why do I have 3 mentions for maillog in logrotate.

    Read the article

  • Use both OpenVPN & eth0 together

    - by shadyabhi
    I connect to a VPN using openVPN. Now, after the connection is established, all my traffic goes through tun0. My LAN gateway is 10.100.98.4... So, for apps to use my direct internet connnection I did sudo route add default gw 10.100.98.4 But, I cant use tun0 now. I know this because curl --interface tun0 google.com doesnt give me anything.. How do I go about using both connections simultaneously. How can I achieve that? ROUTING TABLES:- Without VPN running:- Destination Gateway Genmask Flags Metric Ref Use Iface 10.100.98.0 * 255.255.255.0 U 1 0 0 eth0 default 10.100.98.4 0.0.0.0 UG 0 0 0 eth0 With VPN:- Destination Gateway Genmask Flags Metric Ref Use Iface 10.10.0.1 10.10.54.230 255.255.255.255 UGH 0 0 0 tun0 10.10.54.230 * 255.255.255.255 UH 0 0 0 tun0 free-vpn.torvpn 10.100.98.4 255.255.255.255 UGH 0 0 0 eth0 10.100.98.0 * 255.255.255.0 U 1 0 0 eth0 default 10.10.54.230 0.0.0.0 UG 0 0 0 tun0 After the route command- Destination Gateway Genmask Flags Metric Ref Use Iface 10.10.0.1 10.10.54.230 255.255.255.255 UGH 0 0 0 tun0 10.10.54.230 * 255.255.255.255 UH 0 0 0 tun0 free-vpn.torvpn 10.100.98.4 255.255.255.255 UGH 0 0 0 eth0 10.100.98.0 * 255.255.255.0 U 1 0 0 eth0 default 10.100.98.4 0.0.0.0 UG 0 0 0 eth0 default 10.10.54.230 0.0.0.0 UG 0 0 0 tun0

    Read the article

  • Properly escaping check_command in nagios

    - by shadyabhi
    When I execute sudo -u nagios /usr/lib64/nagios/plugins/check_by_ssh.sh hostname "check_haproxy -u \"http://localhost:10000/haproxy?stats\;csv\"" it runs perfectly on the server. For this, I have this in my HAProxy.cfg define service { use generic-service hostgroup_name pwmail-ee-oxweb service_description HAProxy-ee servicegroups ssh-dep check_command check_by_ssh!check_haproxy -u \"http://localhost:10000/haproxy?stats\;csv\" contacts sysad,mail-hosting-rt } It doesn't work. Says that Return code of 127 is out of bounds - plugin may be missing. What am I doing wrong?

    Read the article

  • Using pthread to perform matrix multiplication

    - by shadyabhi
    I have both matrices containing only ones and each array has 500 rows and columns. So, the resulting matrix should be a matrix of all elements having value 500. But, I am getting res_mat[0][0]=5000. Even other elements are also 5000. Why? #include<stdio.h> #include<pthread.h> #include<unistd.h> #include<stdlib.h> #define ROWS 500 #define COLUMNS 500 #define N_THREADS 10 int mat1[ROWS][COLUMNS],mat2[ROWS][COLUMNS],res_mat[ROWS][COLUMNS]; void *mult_thread(void *t) { /*This function calculates 50 ROWS of the matrix*/ int starting_row; starting_row = *((int *)t); starting_row = 50 * starting_row; int i,j,k; for (i = starting_row;i<starting_row+50;i++) for (j=0;j<COLUMNS;j++) for (k=0;k<ROWS;k++) res_mat[i][j] += (mat1[i][k] * mat2[k][j]); return; } void fill_matrix(int mat[ROWS][COLUMNS]) { int i,j; for(i=0;i<ROWS;i++) for(j=0;j<COLUMNS;j++) mat[i][j] = 1; } int main() { int n_threads = 10; //10 threads created bcos we have 500 rows and one thread calculates 50 rows int j=0; pthread_t p[n_threads]; fill_matrix(mat1); fill_matrix(mat2); for (j=0;j<10;j++) pthread_create(&p[j],NULL,mult_thread,&j); for (j=0;j<10;j++) pthread_join(p[j],NULL); printf("%d\n",res_mat[0][0]); return 0; }

    Read the article

  • Reading Python Documentation for 3rd party modules

    - by Shadyabhi
    I recently downloaded IMDbpy moduele.. When I do, import imdb help(imdb) i dont get the full documentation.. I have to do im = imdb.IMDb() help(im) to see the available methods. I dont like this console interface. Is there any better way of reading the doc. I mean all the doc related to module imdb in one page..

    Read the article

  • Extract strings in python

    - by shadyabhi
    Basically, I want to extract the strings "AAA", "BBB", "CCC", "DDD" from a text file.. ...... (other text goes here)..... <TD align="left" class=texttd><font class='textfont'>AAA</font></TD> ..... (useless text here)..... <TD align="left" class=texttd><font class='textfont'>BBB</font></TD> ....(more text)..... <TD align="left" class=texttd><font class='textfont'>CCC</font></TD> <TD align="left" class=texttd><font class='textfont'>DDD</font></TD> ......(more text)..... I want something like if I do:- data = foo("file.txt") i get:- data = ['AAA','BBB','CCC','DDD'] What is the best possible way? My file is not big..

    Read the article

  • How to know if the client has terminated in sockets

    - by shadyabhi
    Suppose, I have a connected socket after writing this code.. if ((sd = accept(socket_d, (struct sockaddr *)&client_addr, &alen)) < 0) { perror("accept failed\n"); exit(1); } How can I know at the server side that client has exited. My whole program actually does the following.. Accepts a connection from client Starts a new thread that reads messages from that particular client and then broadcast this message to all the connected clients. If you want to see the whole code... In this whole code. I am also struggling with one more problem that whenever I kill a client with Ctrl+C, my server terminates abruptly.. It would be nice if anyone could suggest what the problem is.. #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <signal.h> #include <errno.h> #include <pthread.h> /*CONSTANTS*/ #define DEFAULT_PORT 10000 #define LISTEN_QUEUE_LIMIT 6 #define TOTAL_CLIENTS 10 #define CHAR_BUFFER 256 /*GLOBAL VARIABLE*/ int current_client = 0; int connected_clients[TOTAL_CLIENTS]; extern int errno; void *client_handler(void * socket_d); int main(int argc, char *argv[]) { struct sockaddr_in server_addr;/* structure to hold server's address*/ int socket_d; /* listening socket descriptor */ int port; /* protocol port number */ int option_value; /* needed for setsockopt */ pthread_t tid[TOTAL_CLIENTS]; port = (argc > 1)?atoi(argv[1]):DEFAULT_PORT; /* Socket Server address structure */ memset((char *)&server_addr, 0, sizeof(server_addr)); server_addr.sin_family = AF_INET; /* set family to Internet */ server_addr.sin_addr.s_addr = INADDR_ANY; /* set the local IP address */ server_addr.sin_port = htons((u_short)port); /* Set port */ /* Create socket */ if ( (socket_d = socket(PF_INET, SOCK_STREAM, 0)) < 0) { fprintf(stderr, "socket creation failed\n"); exit(1); } /* Make listening socket's port reusable */ if (setsockopt(socket_d, SOL_SOCKET, SO_REUSEADDR, (char *)&option_value, sizeof(option_value)) < 0) { fprintf(stderr, "setsockopt failure\n"); exit(1); } /* Bind a local address to the socket */ if (bind(socket_d, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) { fprintf(stderr, "bind failed\n"); exit(1); } /* Specify size of request queue */ if (listen(socket_d, LISTEN_QUEUE_LIMIT) < 0) { fprintf(stderr, "listen failed\n"); exit(1); } memset(connected_clients,0,sizeof(int)*TOTAL_CLIENTS); for (;;) { struct sockaddr_in client_addr; /* structure to hold client's address*/ int alen = sizeof(client_addr); /* length of address */ int sd; /* connected socket descriptor */ if ((sd = accept(socket_d, (struct sockaddr *)&client_addr, &alen)) < 0) { perror("accept failed\n"); exit(1); } else printf("\n I got a connection from (%s , %d)\n",inet_ntoa(client_addr.sin_addr),ntohs(client_addr.sin_port)); if (pthread_create(&tid[current_client],NULL,(void *)client_handler,(void *)sd) != 0) { perror("pthread_create error"); continue; } connected_clients[current_client]=sd; current_client++; /*Incrementing Client number*/ } return 0; } void *client_handler(void *connected_socket) { int sd; sd = (int)connected_socket; for ( ; ; ) { ssize_t n; char buffer[CHAR_BUFFER]; for ( ; ; ) { if (n = read(sd, buffer, sizeof(char)*CHAR_BUFFER) == -1) { perror("Error reading from client"); pthread_exit(1); } int i=0; for (i=0;i<current_client;i++) { if (write(connected_clients[i],buffer,sizeof(char)*CHAR_BUFFER) == -1) perror("Error sending messages to a client while multicasting"); } } } } My client side is this (Maye be irrelevant while answering my question) #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <string.h> #include <stdlib.h> void error(char *msg) { perror(msg); exit(0); } void *listen_for_message(void * fd) { int sockfd = (int)fd; int n; char buffer[256]; bzero(buffer,256); printf("YOUR MESSAGE: "); fflush(stdout); while (1) { n = read(sockfd,buffer,256); if (n < 0) error("ERROR reading from socket"); if (n == 0) pthread_exit(1); printf("\nMESSAGE BROADCAST: %sYOUR MESSAGE: ",buffer); fflush(stdout); } } int main(int argc, char *argv[]) { int sockfd, portno, n; struct sockaddr_in serv_addr; struct hostent *server; pthread_t read_message; char buffer[256]; if (argc < 3) { fprintf(stderr,"usage %s hostname port\n", argv[0]); exit(0); } portno = atoi(argv[2]); sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) error("ERROR opening socket"); server = gethostbyname(argv[1]); if (server == NULL) { fprintf(stderr,"ERROR, no such host\n"); exit(0); } bzero((char *) &serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length); serv_addr.sin_port = htons(portno); if (connect(sockfd,&serv_addr,sizeof(serv_addr)) < 0) error("ERROR connecting"); bzero(buffer,256); if (pthread_create(&read_message,NULL,(void *)listen_for_message,(void *)sockfd) !=0 ) { perror("error creating thread"); } while (1) { fgets(buffer,255,stdin); n = write(sockfd,buffer,256); if (n < 0) error("ERROR writing to socket"); bzero(buffer,256); } return 0; }

    Read the article

  • Should I use fork or threads?

    - by shadyabhi
    In my script, I have a function foo which basically uses pynotify to notify user about something repeatedly after a time interval say 15 minutes. def foo: while True: """Does something""" time.sleep(900) My main script has to interact with user & does all other things so I just cant call the foo() function. directly. Whats the better way of doing it and why? Using fork or threads?

    Read the article

  • Cannot press QPushButton in a simple program

    - by shadyabhi
    Basically, I want a simple pushButton with a colorful text which when pressed exits the application. Why cant I press PushButton in this simple program. I am using QT 4.6 on Arch x86_64. #include <QtGui/QApplication> #include <QLabel> #include <QPushButton> #include<QtGui> int main(int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow *Main=new QMainWindow; QPushButton *button = new QPushButton(Main); QLabel *label = new QLabel(Main); label->setText("<h2><i>Hello</i> ""<font color=red>Qt!</font></h2>"); label->setVisible(true); QObject::connect(button, SIGNAL(clicked()),label, SLOT(clear())); label->setAlignment(Qt::AlignCenter|Qt::AlignVCenter); label->setWindowTitle("HelloWorld Test Program"); Main->show(); return a.exec(); }

    Read the article

1 2  | Next Page >