but anyway, by curiosity, why res had changed to not accessible? i did not change it anywhere
Type: Posts; User: tindala
but anyway, by curiosity, why res had changed to not accessible? i did not change it anywhere
hints.ai_flags=AI_CANONNAME | AI_NUMERICSERV;
addrlen=sizeof(*res);
recvfrom(fd,buffer,BUFLEN,0,(struct sockaddr*)res, &addrlen);
+++++++++
thank u very much for the help, i was hanging...
#define _POSIX_C_SOURCE 1
#define _XOPEN_SOURCE
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include...
for example the following piece of code works,
int main(void)
{
struct addrinfo *result;
struct addrinfo *res;
int error;
thank u for the answering, but why it was not able to resolve the name? is there a way to find out?
Hi,
i have seen this thread:
http://cboard.cprogramming.com/linux-programming/94179-getnameinfo.html
and i have also tried it
so, my code is the following:
int main(int argc, char *...
first of all i want to be able to send the message from client to the server. i have more questions about my code, but 1st of all i want to solve that problem.
my code is very similar to this one:...
client.c
reset; gcc -g -Wall -ansi -pedantic client.c -o tt
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include...
@Click_here, thank you for the answer, i liked ur example to show me how that thing is properly used in some situations.
@anduril462, thank u for the clever answer.
and if i change to :
sscanf(str, "%*s %c;%c;%c", arg2, arg3, arg4);
it is still now working :(
and the way have made to make my objective is the only...
Hi,
#define MAX_READ 100
int main(int argc, char **argv)
{
char *str="DNS guu.ssl;124.138.1.25;60000";
char arg1[MAX_READ];
char arg2[MAX_READ];
hi,
i would like to know if i need to dinamically allocate a string in main before passing it to a function that i have created.
in that function i just read the string and do not change any chat...
@grumpy thank you very much for the answer, u got me a very good answer. that clarified me a lot.
char *command_string;
command_string = malloc(BUFLEN * sizeof(*command_string));
isnt the...
@africanwizz , thank you for the usefull link, but i just explained part of my problem, btw can u give me some examples for what is explained in that page, nammely:
""
There is nothing wrong with...
why i do not have to cast the malloc? i have seen many examples on the internet that are casting.
furthermore, if i would like to keep char command_string[BUFLEN];
then how do i allocate memory...
#define BUFLEN 512
int main(int argc, char **argv)
{
char command_string[BUFLEN];
command_string=(char*)malloc(BUFLEN * sizeof(char));
if(command_string==NULL)
{...
@anduril462 thank you very much for the answer.
that solved my problem.
Hi,
thaank you for the answer, i got the following message when using perror: The following error occurred: Cannot assign requested address
i used the following iunstruction perror ("The...
hi,
i have this piece of code:
/* compilation options: reset; gcc -g -Wall -ansi -pedantic testes.c -o tt */
#define _POSIX_C_SOURCE 200112L
#define _XOPEN_SOURCE 600...
#include <stdio.h>
#include <stdlib.h>
#define MAX_READ 2
int main( )
{
char * secret = "abecedarium consisting This is a string literal!";
char command[MAX_READ], string[MAX_READ];
...
i am compiling with the following options: gcc -g -Wall -ansi -pedantic testes.c -o tt
hi,
i have this code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
i am trying to better understand the function getservbyname() with some examples
here : services(5) - Linux manual page i found this phrase: port number (and protocol) for its service
and here : getaddrinfo(3) - Linux manual page
i found the name service which is treated as...
ok, what is the diff betwen service and IP?
service is the port?
i have seen this page:
services(5) - Linux manual page
but i still do not understand it properly