General :: Passing A Structure In A Socket?

Mar 31, 2011

So I'm trying to teach myself to write programs for unix in c. I am currently creating a program, and I need to pass a struct through a socket

The struct I want to pass has two types in it, one enum and one union of two other structs. These two other structs each contain an int and a char variablename[256] array.

gcc won't let me just pass the struct using write(pipefd[1], struct, size_of_struct) since the struct is not a char buffer. So that's my question...how does one go about passing a struct?

View 1 Replies


ADVERTISEMENT

General :: Socket Programming - Feed Some Words One By One To The Socket

Jul 6, 2010

i'm writing a simple program of client socket program. Here below is the code sample which i'm writing...

Code:
//tcp_client.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include<string.h>
#include<stdlib.h>
[Code].....

the above code works fine.if we copmile and run ./a.exe 192.xx.xx.xxx 1111 and press enter it works fine..everytime it asks "Please enter the message: " and if give that will be displayed in server. but my problem is i dont want to print everytime "Please enter the message: " i just want to feed some words one by one to the socket.

View 4 Replies View Related

General :: Socket Error / Socket 31: 0x36?

Sep 15, 2009

We are seeing recv err on socket 31: 0x36. What could be meaning of the error?.

View 1 Replies View Related

Networking :: Configuring Socket Timer To Release Socket Once The Connection Is Terminated?

Jun 4, 2010

I want to configure socket timer to release socket(port) once the connection is terminated. Do we have something in Linux OS to configure this delay to release socket?.

Any command, link or man-page anything will be helpful.

I browsed a lot but unable to find it.

View 1 Replies View Related

Server :: Socket Connections / Socket And TCP Connection For Connecting To An External System?

Dec 7, 2010

Anyone knows the difference between a socket and TCP connection for connecting to an external system?

View 1 Replies View Related

Networking :: /usr/sbin/in.telnetd: Getpeername: Socket Operation On Non-socket?

May 5, 2009

I had installed Fedora 10

Below is the output of uname -a

Linux 2.6.27.5-117.fc10.i686.PAE #1 SMP Tue Nov 18 12:08:10 EST 2008 i686 i686 i386 GNU/Linux

I need to enable telnet service on it, then found xinetd and telnet-server not installed,

Then I had installed below
First I had installed Xinetd: xinetd-2.3.14-21.fc10.i386.rpm
then I had installed telnet-server: xinetd-2.3.14-21.fc10.i386.rpm

After installation I executed below commands

Service xinetd start
Chkconfig xinetd on
Chkconfig telnet on
Service iptables stop
Chkconfig iptables off
Iptables �F

After I had tried telnet localhost ----IT FAILED

when I run telnet server manually by issuing the below command
/usr/sbin/in.telnetd, I get below error
[COLOR="Red"]/usr/sbin/in.telnetd: getpeername: Socket operation on non-socket[/COLOR]

I have other system running same OS, I had followed the same steps discussed above to enable telnet, It works fine on it.

View 1 Replies View Related

Programming :: Setsockopt : Socket Operation On Non-socket Getting Error?

Mar 30, 2009

im getting that error in my code for some reason. I compiled my code, and when i try to run this server it throws me an error on my call to setsocketopt(). The only way it can reach that part of my loop is if it succeeds when it calls sock() so I dont understand why the error says its an operation on a non-socket. Im just trying to set up a server to pass messages from a client to it a viceversa. Here is the code:

Code:
int main()
{
int socket_fd, new_socket_fd, k;
struct addrinfo hints, *server_info, *p;
struct sockaddr_storage peer_address;
code....

View 7 Replies View Related

Networking :: Multiple FTP Upload Socket Error "Connection Reset By Peer: Socket Write"

Jan 31, 2010

I am pragmatically trying to upload a list of files from my client machine to a proFTPd server I have running on Ubuntu. Every time I get several (around fifty) files into the transfer, I get the following error: Quote: Connection reset by peer: socket write error

I am able to remotely upload 25,000 small files of ~ 1K in size, but when I go to upload hundreds of 2-4 Mb files, I get a socket write error. Am I using up all available sockets before they can be released? If so, how do I release the sockets? If not, what does this error mean and why am I getting it?

View 1 Replies View Related

General :: Set Up A Directory Structure ?

Jul 16, 2011

i just started dabbling with this Linux program Fedora and i go to school for cpu forencics but havnt reached Linux+ yet.

View 13 Replies View Related

General :: Set Directory Structure In Git ?

Jun 24, 2011

I've the following file structure that I would like to add to git.

Code:

These are big directories and I don't need them all checked out. I only need the src directory. After I commit the files in the /app/src, it must be pushed to a remote site.

If I want only to checkout the src directory to work on, it's important to create a special file structure in git? For example, instead of doing git init on app general directory, should I do git init on all subdirectories?

Is it possible to checkout only part of a file structure in git?

View 1 Replies View Related

General :: Passing One Variable To Another

Jan 8, 2011

I am new to bash scripting. I want to know whether i can pass one variable to another. For example $1 represent argument1. Now if i want to get the argument 1 like USER="1" now i want $ of $USER to execute $1 so what should i do..

View 2 Replies View Related

General :: Directory Structure For Building RPM

Mar 20, 2011

My clearly outdated Linux course I'M using is telling me that the directory structure for building RPMs is in /usr/src/redhat, but on my redhat system, there is only /usr/src/ > debug & > kernels, folders.

View 5 Replies View Related

General :: Pthreads - Structure Can Be Returned With Value

May 21, 2010

I am playing around with pthreads. This program however blows up.

#include <iostream>
#include <pthread.h>
using namespace std;
struct myStruct
{
int a;
string msg;
};

void * myProc(void *arg)
{
struct myStruct* str = new struct myStruct();
str->a = 10;
str->msg ="hi";
return (void*)str;
}

int main(int argc, char **argv)
{
pthread_t mythr;
int status ;
void *retVal;
struct myStruct* m_str;
status = pthread_create(&mythr,NULL,myProc,NULL);
status = pthread_join(mythr,&retVal);
cout<<"Status is"<<status<<endl;
m_str = (struct myStruct*)m_str;
cout<<"retval is "<<m_str->a<<" "<<endl;
return 0;
}

Can a structure be returned by a thread as its return value ?

View 1 Replies View Related

General :: Passing PATH Through Sudo?

Jan 21, 2010

In short: how to make sudo not to flush PATH everytime?

I have some websites deployed on my server (Debian testing) written with Ruby on Rails. I use Mongrel+Nginx to host them, but there is one problem that comes when I need to restart Mongrel (e.g. after making some changes).

All sites are checked in VCS (git, but it is not important) and have owner and group set to my user, whereas Mongrel runs under the, huh, mongrel user that is severely restricted in it's rights. So Mongrel must be started under root (it can automatically change UID) or mongrel.

To manage mongrel I use mongrel_cluster gem because it allows starting or stopping any amount of Mongrel servers with just one command. But it needs the directory /var/lib/gems/1.8/bin to be in PATH: this is not enough to start it with absolute path.

Modifying PATH in root .bashrc changed nothing, tweaking sudo's env_reset and env_keep didn't either.

So the question: how to add a directory to PATH or keep user's PATH in sudo?

Update: some examples

$ env | grep PATH
PATH=/usr/local/bin:/usr/bin:/bin:/usr/games:/var/lib/gems/1.8/bin
$ sudo cat /etc/sudoers | egrep -v '^$|^#'
Defaults env_keep = "PATH"

[Code]....

View 4 Replies View Related

General :: Passing Program Arguments To Gdb?

Nov 18, 2009

I'm using gdb to debug my program. My program requires arguments (e.g., ./prog -dfile).But if I use gdb as in gdb ./prog -dfile, gdb wants to interpret the -d argument. How do I pass an argument to my program via gdb?

View 2 Replies View Related

General :: Passing Parameters To Script ?

Mar 13, 2010

I have the following bash script:

Code:

Which has the name 'extractemails.sh' and works just fine.

However, i whish to be able to give the url (or any other url) as a parameter when i run the script like this: $ extractemails.sh [url]

What should i change in my code? i have never tried passing parameters to scripts before.

View 4 Replies View Related

General :: Error - Read Only Directory Structure

May 20, 2010

I am using RHEL 4.4. Last time when I reboot my server it generate an error, and mention to run fsck command in repair mode. When I ran, this fix some problems, but after that it generate an error of gdm and X11 services after showing login sceen and getting user name and passwod. But I login via putty from a remote system. So, when I tried to make changes like create directory or file or even tried to make any change in any file it generate an error that " you can not make changes in read only file system".

View 10 Replies View Related

General :: Binary Compare Of Directory Structure

Apr 13, 2011

diff has the ability to trasverse directory structures. cmp has the ability to manage binary files.

I'm looking for something which allows me to compare a directory's contents, including files and subdirectories, and so a binary comparison.

Any suggestions, scripts, etc. which may be of help?

Some of my directories are huge, with huge (image) files in them.

View 2 Replies View Related

General :: Downloading Files With Same Directory Structure

Apr 8, 2010

How do I download all the files form here: [URL]. I am on freeBSD 7.0 and I tried wget with the -r switch and it gives me URL's only. Maybe this is simply not an ftp site I don't know. How I can download all those files with the same directory structure.

View 5 Replies View Related

General :: Plot Band Structure Using Wien2k?

Sep 28, 2010

I want to plot band structure using Wien2k and for this I have to make a file named "case.klist_band". But I have a Rhomhedral compound . There is written to make the file using xcrysden but I donot know how to make the file from xcrysden.

View 2 Replies View Related

General :: Bash - Passing Commands To CLI Using A Script

Jul 31, 2011

is there any way I can pass commands to the CLI of a tool directly?

I would like to script some actions, for example:

./OpenBTS < "tmsis"

I do not need to retrieve the results (I watch it in the log file). how I could realize that? There is now way to do this using command line parameters, at least not that I found out. So it looks like I have to figure out sth myself. Maybe I could automate screen in a way to detect the prompt and "paste" my command there. Are there tools for this on Linux?

View 3 Replies View Related

General :: Passing SSH A Password Through Command Line?

Aug 4, 2010

I am writing a script to get hardware information of a particular UNIX machine. To do this, I ftp a shell script (commands to get h/w information) to the target machine and then use SSH to remote the remote script.With FTP, I can pass a password accepted as input the shell script. How can I pass the same password to SSH ? This is because I do not want the user to enter the password twice.

View 5 Replies View Related

General :: Passing A List Of Variables To A For Loop

Mar 17, 2011

I'm trying to do substitutions to a file based on passed variables.

For example, I have a file called test.txt that has 5 lines:

What I want to do is to go through that file, line by line and check for the presence of a passed variable in that line. If I have a match, then substitute and print, otherwise print line as is. My problem arises in that the number of variables is well, variable.

The code I started with was the following:

Code:

What I was hoping for was test.out to look like this:

What I get is a much longer file like this:

This makes sense after thinking about it but is there anyway to get an output like the first case?

View 5 Replies View Related

Programming :: Socket Programming - Detect Whether A Client Socket Is Closed / Active?

Mar 8, 2011

iam just trying to connect to server which accepts one client and server will read(blocking operation) infinitely, but After closing the client socket the server "read operation" is returning zero and "errno variable(in errno.h)" value is also zero. how can i detect whether a client socket is closed/active..?

client.c
Serv_Addr.sin_family = AF_INET;
Serv_Addr.sin_addr.s_addr = inet_addr("127.0.0.1");
Serv_Addr.sin_port = htons(26553);
if( 0 > connect (Serv_Fds,&Serv_Addr,sizeof(Serv_Addr)) )
{
perror("connect");
return 0;
[Code]....

View 3 Replies View Related

General :: Quick File Structure Question For Any User?

Aug 10, 2009

I have used linux for a web server but only installed a couple items on top of the OS but would like to begin using linux more often on my own home machine. However, I also like to keep things clean and organized, and know what is going on when I do something. I have some sample C scripts for network programming, and they came as a downloadable package with a readme including the make / configure instructions to get it all set up, and then I can compile individual scripts as needed.

I was wondering - when I run make and those first few commands - where does it all go? Will all the new activity be confined to the folder I am in, meaning I can easily remove it all by simply deleting the folder when I am done (I won't want all this sample networking stuff forever, you know). Or, does it get placed into other directories throughout the file system?

I know when installing some apps that the files are placed in directories such as usr/bin and the like - my assumption is this happens when running make and make install commands - if so, how do we get rid of them when finished?

I just want to keep the system somewhat clean if possible, and the very least like to know what is being installed and to where - and have the option to remove it easily at a later date if I choose to do so.

View 2 Replies View Related

General :: Audio Player That Lists By Directory Structure?

Feb 12, 2010

Amarok is nice, and currently the only thing I've tried that will actually play audio from network shares and not lock up. Only problem is that it doesn't seem to list my library by directory/folder structure.. only album/artist/genre or some variation thereof. Is there anything that does list by folder structure?

View 3 Replies View Related

General :: Generate Html Based On Directory Structure?

Jul 22, 2010

does any one knows a linux based program/script that can generate html files based on directory structure?

View 1 Replies View Related

General :: Copy Directory Into Another Preserving Specific Structure?

Jul 20, 2011

I would like to find the command that copy my eclipse options to another workspace code...

It doesn't work, and it could be source of error to write the path .metadata/.plugins manually. It certainly a better idea to create a complete script ?

View 1 Replies View Related

General :: Make Rsync Ignore Directory Structure?

Apr 19, 2011

Is there a way to force rsync to not make directories in its destination directory; ie, to simply dump all of the files from the source directory directly into the destination without copying any of the folders that the files were originally in? I tried --no-dirs, but that seems to only be for empty directories.

View 1 Replies View Related

General :: Renaming A Bunch Of Files Using For-structure And The Mv Command?

Feb 3, 2010

Basically I need to rename a bunch of .doc files using the for-structure and the mv command (w/ wildcards) in bash. I guess this would be a bit easier if I'd use the rename command, but since this is a school assignment of sorts I need to use for & mv. The .doc files are named "1filename.doc", "2filename.doc" etc. And I've got to rename them to "aaa_1filename.doc", "aaa_2filename.doc", "aaa_3filename.doc" and so on. Tried to dabble quite a bit with the for and mv commands, basically just got a bunch of errors. Every damn time. For 2 hours. The most common error was "mv: missing destination file operand after ..."

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved