Sponsored Content
Top Forums Programming Write the source code for messenger Post 302094486 by !_30 on Saturday 28th of October 2006 11:27:05 AM
Old 10-28-2006
Thank's guy's for answering . I found your word's useful. I'm getting over the project , everithing seem's more clearly now.
I have a few things to acommodate and everithing seem's to work just fine.

I only have a question for you.I found myself in a situation , I cannot resolve . Maybe I haven't think for the right choice yet , but you can help me ..

I written the server and client code , for some sort of messenger ( mini-version ) , and I don't know ( I may know , but not having the right idea ) , how to implement something. Smilie

I want to make an easy thing.In the source code for the client , I want to implement someting like this :

-when the client want's to transmit data , it gets the buffer ( getstr(buffer) )
-when something arive at the client , some data , it 's print's the string's arived on main window.

I cannot implement this.How can I implement this in C ? I write some sort of code , down :

Code:
int nbytes;
for (;;)
{
if (nbytes=recv(listener,buf,sizeof(buf),0) >0 )
{
        printw("%s\n",buf);
        refresh();
}
else{

getstr(s);
send(listener,s,sterlen(s),0);}

}

The problem , is that this code , is how you see , non-useful and childish.
I want something simple , when I write data , on the client ( getstr(s) ) , to be sent ( to listener -> server ) and when I receive some data ( string's ) , to be printed on the main window.This is all.
The problem is that I cannot make this ..it block's .If I don't enter a string to be sent to the ( listener -> socket server ) , it won't print ( received data ).

Should I use files ?.. or something like that ..

A help , may be needed , if you guy's get the idea , what I want Smilie
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Where can I review the source code?

A very n00b question: After compiling and installing software, where does the original source code reside? I'd like to study the source code of some of the ports I've installed. Thanks! :D (1 Reply)
Discussion started by: Aaron Van
1 Replies

2. Shell Programming and Scripting

write page source to standard output

I'm new to PERL, but I want to take the page source and write it to a file or standard output. I used perl.org as a test website. Here is the script: use strict; use warnings; use LWP::Simple; getprint('http://www.perl.org') or die 'Unable to get page'; exit 0; ... (1 Reply)
Discussion started by: wxornot
1 Replies

3. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

4. UNIX for Dummies Questions & Answers

Where can i get unix source code?

Sir please tell me where can i get source code for some unix kernal and shell also. (1 Reply)
Discussion started by: VIPUL15
1 Replies

5. Shell Programming and Scripting

Block of code replacement in Java source code through Unix script

Hi, I want to remove the following code from Source files (or replace the code with empty.) from all the source files in given directory. finally { if (null != hibernateSession && hibernateSession.isOpen()) { //hibernateSession.close(); } } It would be great if the script has... (2 Replies)
Discussion started by: hareeshram
2 Replies

6. Linux

Source code

I need the source code of fedora. plz plz plz help me........... (1 Reply)
Discussion started by: neh
1 Replies

7. Shell Programming and Scripting

Source code compilation

Need assistance in Source code compilation . When installing a software compiling a source code . Whatever the output that prints on the screen i want to log it into a file. How can i see output and store the output to file ./configure make make install Is there other way of seeing output... (5 Replies)
Discussion started by: ajayram_arya
5 Replies

8. UNIX for Dummies Questions & Answers

Source code

hii... i am a biginner....and i have linux source code ,downloaded from some website ,a compressed file on windows and dont know how do compile them..... (4 Replies)
Discussion started by: M K Raju
4 Replies
Implementing Servers(3) 				       globus gass transfer					   Implementing Servers(3)

NAME
Implementing Servers - Typedefs typedef void(* globus_gass_transfer_close_callback_t )(void *callback_arg, globus_gass_transfer_listener_t listener) typedef void(* globus_gass_transfer_listen_callback_t )(void *callback_arg, globus_gass_transfer_listener_t listener) Functions int globus_gass_transfer_create_listener (globus_gass_transfer_listener_t *listener, globus_gass_transfer_listenerattr_t *attr, char *scheme) int globus_gass_transfer_close_listener (globus_gass_transfer_listener_t listener, globus_gass_transfer_close_callback_t callback, void *user_arg) int globus_gass_transfer_register_listen (globus_gass_transfer_listener_t listener, globus_gass_transfer_listen_callback_t callback, void *user_arg) int globus_gass_transfer_register_accept (globus_gass_transfer_request_t *request, globus_gass_transfer_requestattr_t *attr, globus_gass_transfer_listener_t listener, globus_gass_transfer_callback_t callback, void *user_arg) void * globus_gass_transfer_listener_get_user_pointer (globus_gass_transfer_listener_t listener) int globus_gass_transfer_listener_set_user_pointer (globus_gass_transfer_listener_t listener, void *user_pointer) char * globus_gass_transfer_listener_get_base_url (globus_gass_transfer_listener_t listener) int globus_gass_transfer_refer (globus_gass_transfer_request_t request, char **urls, globus_size_t num_urls) int globus_gass_transfer_authorize (globus_gass_transfer_request_t request, globus_size_t total_length) int globus_gass_transfer_deny (globus_gass_transfer_request_t request, int reason, char *message) Detailed Description GASS Server Implementation API. Another mode of using the GASS Transfer API is to implement data servers. The primary difference between the client and server parts of the GASS Transfer API are how requests are generated. To implement a server, the user would call globus_gass_transfer_create_listener() to create a new server port on which a specific protocol will be used to request file transfer operations. The user may obtain the URL that the listener is bound to by calling globus_gass_transfer_listener_get_base_url(). Once the listener is created, the user can call globus_gass_transfer_register_listen() to wait for clients to connect to it. Once the server has detected an attempt to connect by a client, the use can call globus_gass_transfer_register_accept() to accept the connection from the client and parse the request. In the callback associated with globus_gass_transfer_register_accept(), the server can decide how to process the request. The user may choose to authorize the request by calling globus_gass_transfer_authorize(), refer it to another URL or URLs by calling globus_gass_transfer_refer() or deny the client access to the URL by calling globus_gass_transfer_deny(). Typedef Documentation typedef void(* globus_gass_transfer_close_callback_t)(void *callback_arg, globus_gass_transfer_listener_t listener) Listener close callback. Parameters: callback_arg listener typedef void(* globus_gass_transfer_listen_callback_t)(void *callback_arg, globus_gass_transfer_listener_t listener) Listen callback. Parameters: callback_arg listener Function Documentation int globus_gass_transfer_create_listener (globus_gass_transfer_listener_t *listener, globus_gass_transfer_listenerattr_t *attr, char *scheme) Create a new protocol-specific listener socket for a GASS server. This function creates a new socket to listen for client connections as a GASS server. The listener handle pointer is initialized to contain the a new handle which can be used in subsequent server operations. After calling this function, a user may call the globus_gass_transfer_register_listen() or globus_gass_transfer_close_listener() functions with this listener handle. Parameters: listener A new listener handle to initialize. attr Protocol-specific attributes for the new listener. scheme The protocol scheme to implement for the listener. Return values: GLOBUS_SUCCESS The listener was successfully created. GLOBUS_GASS_TRANSFER_ERROR_NULL_POINTER The listener or scheme parameter was NULL GLOBUS_GASS_TRANSFER_ERROR_NOT_IMPLEMENTED The scheme is not supported by any protocol module. GLOBUS_GASS_TRANSFER_ERROR_MALLOC_FAILED Data structures associated with the transfer could not be allocated. int globus_gass_transfer_close_listener (globus_gass_transfer_listener_tlistener, globus_gass_transfer_close_callback_tcallback, void *user_arg) Close a GASS listener. This function calls the protocol specific function needed to close a GASS server listener port. Callbacks for any outstanding accepts will be called before the close callback is invoked. Parameters: listener Listener handle created by calling globus_gass_transfer_create_listener(). callback Function to call once the listener handle has been closed. user_arg Argument to be passed to the callback function. Return values: GLOBUS_SUCCESS The close operation was successfully registered on the listener. GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE The listener handle was invalid. GLOBUS_GASS_TRANSFER_ERROR_NOT_INITIALIZED The listener handle was not properly initialized. GLOBUS_GASS_TRANSFER_ERROR_DONE A close has already been registered on the listener. int globus_gass_transfer_register_listen (globus_gass_transfer_listener_tlistener, globus_gass_transfer_listen_callback_tcallback, void *user_arg) Listen for new client connections. This function causes the listener handle to listen for new client connections. When one is ready, it calls the specified callback function, letting the server implementer continue to accept the connection and process the request. Parameters: listener The listener handle to register for new connections. callback Function to call when a new connection may be accepted. user_arg Argument to be passed to the callback function. Return values: GLOBUS_SUCCESS The listen callback has been registered with the protocol module. GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE An invalid listener handle was passed to this function. GLOBUS_GASS_TRANSFER_ERROR_NOT_INITIALIZED An uninitialized listener handle was passed to this function. GLOBUS_GASS_TRANSFER_ERROR_ALREADY_REGISTERED The listener has already been registered for a new connection. GLOBUS_GASS_TRANSFER_ERROR_DONE The listener has been registered for closing. See also: globus_gass_transfer_register_accept(); int globus_gass_transfer_register_accept (globus_gass_transfer_request_t *request, globus_gass_transfer_requestattr_t *attr, globus_gass_transfer_listener_tlistener, globus_gass_transfer_callback_tcallback, void *user_arg) Accept new client connections. This function causes the listener handle to accept a new connection on the listener and parse the file request. Once the file request has been parsed, the specified callback function will be called. The server implementation must then either authorize, deny, or refer this request. Parameters: request A pointer to a new request handle. This request handle will be initialized when the callback function is invoked. attr Request attributes. listener The listener handle to register for the new request. callback Function to call when the protocol module has parsed the file request. user_arg Argument to be passed to the callback function. Return values: GLOBUS_SUCCESS The listen callback has been registered with the protocol module. GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE An invalid listener handle was passed to this function. GLOBUS_GASS_TRANSFER_ERROR_NOT_INITIALIZED An uninitialized listener handle was passed to this function. GLOBUS_GASS_TRANSFER_ERROR_INTERNAL_ERROR The request could not be initialized due to some internal resource depletion. GLOBUS_GASS_NOT_REGISTERED. The globus_gass_transfer_register_listen() function has not yet been called. GLOBUS_GASS_ALREADY_REGISTERED. The listener is already processing a new request. GLOBUS_GASS_TRANSFER_ERROR_DONE The listener has been registered for closing. See also: globus_gass_transfer_register_listen(); void* globus_gass_transfer_listener_get_user_pointer (globus_gass_transfer_listener_tlistener) Get the user pointer associated with a listener. This function will query the listener's user_pointer field and return it's value. Parameters: listener The listener handle. Returns: If the listener handle is invalid or the user_pointer's value has not been set, then GLOBUS_NULL will be returned. Otherwise, the value of the user pointer will be returned. See also: globus_gass_transfer_listener_set_user_pointer() int globus_gass_transfer_listener_set_user_pointer (globus_gass_transfer_listener_tlistener, void *user_pointer) Set the user pointer associated with a listener. This function will set the listener's user_pointer field. The pointer may be used to associate any pointer-sized data with a listener handle. Parameters: listener The listener handle. user_pointer The value of the user pointer. Return values: GLOBUS_SUCCESS The user pointer was successfully set. GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE The listener handle was invalid. See also: globus_gass_transfer_listener_get_user_pointer() char* globus_gass_transfer_listener_get_base_url (globus_gass_transfer_listener_tlistener) Get the base URL of a listener. This function queries a listener handle for the base URL which the server is listening on. For most protocols, this contains the protocol scheme, host, and port that the listener has registered itself on. Parameters: listener The listener handle to query. Returns: This function returns a pointer to a string containing the base URL. This string must not be freed or modified by the caller. It may not be referred to after the function globus_gass_transfer_listener_close() has been called. int globus_gass_transfer_refer (globus_gass_transfer_request_trequest, char **urls, globus_size_tnum_urls) Refer a request. This function causes the request to be referred to another URL or list of URLs. It should be called in response to a request accept callback when the server wants to refer the client to another server or servers to process the request. Parameters: request A new request handle, passed to the server in an accept callback. urls An array of strings, each being a URL pointing to sources of the same data as the original URL. num_urls The length of the urls array. Return values: GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE The request handle was not valid, not created by calling globus_gass_transfer_register_accept(), or has already been denied or authorized. GLOBUS_GASS_TRANSFER_ERROR_NOT_IMPLEMENTED The protocol module does not support referrals. See also: globus_gass_transfer_deny(), globus_gass_transfer_authorize() int globus_gass_transfer_authorize (globus_gass_transfer_request_trequest, globus_size_ttotal_length) Authorize a request. This function causes the request to be authorized for processing. It should be called in response to a request accept callback when the server wants to agree to process this request. After calling this function, the server implementation should call globus_gass_transfer_send_bytes() or globus_gass_transfer_receive_bytes() to send or receive the data associated with the URL. Parameters: request A new request handle, passed to the server in an accept callback. total_length For a 'get' request, the total_length of the file to be retrieved if known. This value may be GLOBUS_GASS_LENGTH_UNKNOWN if the protocol supports transferring arbitrarily-sized files. Return values: GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE The request handle was not valid, not created by calling globus_gass_transfer_register_accept(), or has already been denied or authorized. GLOBUS_GASS_TRANSFER_ERROR_NOT_IMPLEMENTED The protocol module does not support authorizing requests. See also: globus_gass_transfer_refer(), globus_gass_transfer_deny() int globus_gass_transfer_deny (globus_gass_transfer_request_trequest, intreason, char *message) Deny a request. This function causes the request to be denied for further processing. It should be called in response to a request ccept callback when the server wants to refuse processing this request for the client. After calling this function, the server implementation need do nothing further with the request handle. Parameters: request A new request handle, passed to the server in an accept callback. reason A protocol-specific reason code. message An informational message to be sent to the client. Return values: GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE The request handle was not valid, not created by calling globus_gass_transfer_register_accept(), or has already been denied or authorized. GLOBUS_GASS_TRANSFER_ERROR_NOT_IMPLEMENTED The protocol module does not support denying requests. See also: globus_gass_transfer_refer(), globus_gass_transfer_authorize() Author Generated automatically by Doxygen for globus gass transfer from the source code. Version 7.2 Mon Apr 30 2012 Implementing Servers(3)
All times are GMT -4. The time now is 06:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy