c

What is a good way to connect multiple clients to the server?

Hi, As there are serveral ways of connecting multiclients to the server such as: fork, select, threads, etc. I would be glad if you could describe which is better to connect multiple clients to the server? Thanks for you time and reply? ...

How to pass data from client to server when using gSOAP ?

I am trying to exchange data between client and server using gSOAP. Actually, I succeeded to send data from client to server but not from server to client. So, could someone please explain what functions to use to pass data from server to client? Thanks for your time and replies, ...

What is the difference between soap_new() and soap_copy()?

What is the difference between: thread_envs[i] = soap_copy(&env); and thread_envs[i] = soap_new(); Sould we use one of them or both? ...

minor issue with fork() and pipe()

I 'm writing a little program that implements pipes like they work in the shell. ie: ls -hal | sort | grep p | wc it works fine, with the minor issue that on one line, when CMD_NO=n, the comparison i biggerthan CMD_NO does not work, but i!=(CMD_NO-1) does. I'm trying to figure out why in this particular case (the line is ocmmented a...

Ruby C extensions, Use Ruby data types or native C for performance?

I'm currently writing a C extension for ruby as part of a project of mine. The extension is to implement an algorithm I have already working in ruby in C for performance reasons. The question I pose though is whether I should use ruby's own data types in the C code or convert them to C's native types for performance reasons? Would such...

C - trying to read a single char from stdin (and failing) w/ scanf / getchar

Hi - as a part of a homework assignment, I'm trying to read a single char from stdin, and act according to it: char choice; while (1) { printf("please enter [y]es, [n]o or [m]aybe: "); scanf("%c", choice); fflush(stdin); // validate input if (choice == 'y' || choice == 'n' || choice == 'm') { break; } el...

How to write a simple text based protocol, preferably in C

I'm interested in writing a small piece of sample code that communications via standard TCP/IP means to an application server. The idea here is that the client can speak to the application server and be authenticated by simply speaking in a specific text based protocol. The traffic will be encrypted, no username/password. If another app ...

C - need to detect presence of digit in a number (hw)

Hello - I'm trying to write a function that'll detect if a digit is found in a number: // returns 1 if source contains num, 0 otherwise int contains_num(source, num); for example, contains_num(12345, 3) returns 1 and contains_num(12345, 6) returns 0. I'm not sure how to go about solving this. Probably can't use pointers, arrays and s...

how to use omp barrier on a while loop with no equal number of iterations for threads

Hi! I'm trying to implement the listranking problem (known also by shortcutting) with omp to have the sums prefixes of the array W. I don't know if i use correctly the flush pragma.. And i have a warning when compiling "barrier region may not be closely nested inside of work-sharing, critical, ordered, master or explicit task region" #i...

C: Allocate memory ahead or on every demand?

Hi, I've got a simple (propably) question for you. When creating own dynamic array implementation in C, is it better to allocate memory ahead(let's presume, for 10 elements) when an array is close to reach its current maximum capability, or to realloc memory every time when element count changes? I mean: for performance, elegance or w...

Threading on bootloader

Where can I find resources/tutorials on how to implement threads on a x86 architecture bootloader... lets say I want to load resources in the background while displaying a progress bar.. ...

How can I determine the space/size of my drive programatically? Both in LInux and on Windows.

That is : How can I check the drive size which is not formatted... Don't consider the formatted drives...just unformatted drive. ...

Delete a node in singly link list

How to delete a node in a singly link list with only one pointer pointing to node to be deleted? [Start and end pointers are not known, the available information is pointer to node which should be deleted] ...

Why the swap program which collects addresses in pointers to pointers did not work ?

I have a program below void swap(char **s1,char **s2); int main() { char *list[] = { "Das", "Kannan", "Rajendran", "Shahul" }; printf("Before swap list[0] = %s,list[1] = %s\n",*list[0],*list[1]); swap(&list[0],&list[1]); printf("After swap list[0] = %s,list[1] = %s\n",*list[0],*list[1]); retur...

Show results of fgetc as character on screen

Hi, I am trying to debug the following code: int check_file(FILE* file) { int c; int nl = '\n'; while((c = fgetc(file)) != EOF) { if (c == nl) return 0; } printf("\n ERROR EOF \n"); return 1; } when it gets error and returns 1, I would like to know the reason. I thought about printing on screen the character r...

Where to find a good tutorial and examples of CSOAP?

I started to work with CSOAP (see http://csoap.sourceforge.net) and when searched on google, I didn't find a good tutorial of CSOAP. Could you plz direct me to anything relevant from where to start? Thanks! ...

Is it possible to get cursor position in C?

Hi, I am reading a file with fgetc, so each time it reads a character, the cursor positio gets changed. Is it possible to know, after each read, the "coordinates" of the cursor on the file in terms of column and line number? Thanks ...

Which one to use - memmove() or memcpy() - when buffers don't overlap?

Using memcpy() when source and destination overlap can lead to undefined behaviour - in those cases only memmove() can be used. But what if I know for sure buffers don't overlap - is there a reason to use specifically memcpy() or specifically memmove()? Which should I use and why? ...

Can I use C to know whether a file operation is performed on the disk at runtime?

Can I use C to know whether a file operation is performed (and where it is performed) on the disk at run time? ...

How can I set options in SConstruct for C compiler depending on compiler type?

I need to set additional options for C compiler, e.g. add flag to turn all warnings ON, depending on the type of the compiler. E.g. for MSVC I should use env.Append(CPPFLAGS = "/Wall") but for mingw (gcc) I need to use: env.Append(CCFLAGS = "-Wall") How can I do this in scons way? ...