Sponsored Content
Full Discussion: Write-Write on a socket
Top Forums Programming Write-Write on a socket Post 302446415 by Corona688 on Wednesday 18th of August 2010 03:00:24 PM
Old 08-18-2010
Nothing bad happens when you write to both ends at the same time. What precisely happens when depends on a lot of things like buffers, framing, and transit time, but two-way traffic is still just business as usual. If the data has arrived by the time one of them finishes a write(), yes, a read() may be able to get it.
 

9 More Discussions You Might Find Interesting

1. Programming

read/write socket error

I have client and server connected. client write and read from csock. server write and read from ssock suppose the server does : .... close(ssock); //send FIN to client othertask(); .... READ ERROR if after the server close() the client does: ... read(csock,...); ...... (2 Replies)
Discussion started by: gio
2 Replies

2. Programming

How to Write Linux Friendly Async Socket I/O

I am presently refactoring a windows deamon with an eye towards porting it to linux someday. Presently the application uses a single background thread and asynchronous socket I/O to implement FTP and HTTP clients in a single switch statement (2000 lines and 100 cases just for the switch... (3 Replies)
Discussion started by: siegfried
3 Replies

3. IP Networking

Can we write a multiple thread to receive from a single socket file descriptor

Hi Friends, I have written a program which will listener for more than 1000 requests per second from a single socket descriptor and then it will process those requestes. Its taking X amount of time. Now i want to reduce that time. Will I can write multiple threads to receive the... (2 Replies)
Discussion started by: pa.chidhambaram
2 Replies

4. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

5. 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

6. Programming

write on Non Blocking Socket

How to know whether socket is ready for write. select(maxfds, (fd_set *)NULL, &writefds, NULL, &timeout); By default socket is set for write without checking whether it would block or not? If so how do I know my FD is ready for writing. (3 Replies)
Discussion started by: satish@123
3 Replies

7. Shell Programming and Scripting

Read and write to tcp socket

Hello all, I have a requirement to read and write to a tcp socket from an HP-UX shell script. I see a /dev/tcp character device on my servers: crw-rw-rw- 1 root root 72 0x00004f Mar 28 18:37 /dev/tcp So I believe this is what I should use. The problem is that all the... (2 Replies)
Discussion started by: lupin..the..3rd
2 Replies

8. Shell Programming and Scripting

Is it possible to write write multiple cronjobs in shellscript??

Hi All, I need the answer of below question? 1) How to write multiple cronjobs in shellscript? Is there any way or we cant write in shellscript... Regards, Priyanka (2 Replies)
Discussion started by: pspriyanka
2 Replies

9. Programming

Interactive Python 3.5+ sys.stdout.write() AND sys.stderr.write() bug?

(Apologies for any typos.) OSX 10.12.3 AND Windows 10. This is for the serious Python experts on at least 3.5.x and above... In script format sys.stdout.write() AND sys.stderr.write() seems to work correctly. Have I found a serious bug in the interactive sys.stdout.write() AND... (2 Replies)
Discussion started by: wisecracker
2 Replies
QSocketNotifier(3qt)													      QSocketNotifier(3qt)

NAME
QSocketNotifier - Support for socket callbacks SYNOPSIS
#include <qsocketnotifier.h> Inherits QObject. Public Members enum Type { Read, Write, Exception } QSocketNotifier ( int socket, Type type, QObject * parent = 0, const char * name = 0 ) ~QSocketNotifier () int socket () const Type type () const bool isEnabled () const virtual void setEnabled ( bool enable ) Signals void activated ( int socket ) DESCRIPTION
The QSocketNotifier class provides support for socket callbacks. This class makes it possible to write asynchronous socket-based code in Qt. Using synchronous socket operations blocks the program, which is clearly not acceptable for an event-driven GUI program. Once you have opened a non-blocking socket (whether for TCP, UDP, a UNIX-domain socket, or any other protocol family your operating system supports), you can create a socket notifier to monitor the socket. Then you connect the activated() signal to the slot you want to be called when a socket event occurs. There are three types of socket notifiers (read, write and exception); you must specify one of these in the constructor. The type specifies when the activated() signal is to be emitted: <ol type=1> 1 QSocketNotifier::Read - There is data to be read (socket read event). 2 QSocketNotifier::Write - Data can be written (socket write event). 3 QSocketNofifier::Exception - An exception has occurred (socket exception event). We recommend against using this. For example, if you need to monitor both reads and writes for the same socket you must create two socket notifiers. Example: int sockfd; // socket identifier struct sockaddr_in sa; // should contain host address sockfd = socket( AF_INET, SOCK_STREAM, 0 ); // create TCP socket // make the socket non-blocking here, usually using fcntl( O_NONBLOCK ) ::connect( sockfd, (struct sockaddr*)&sa, // connect to host sizeof(sa) ); // NOT QObject::connect()! QSocketNotifier *sn; sn = new QSocketNotifier( sockfd, QSocketNotifier::Read, parent ); QObject::connect( sn, SIGNAL(activated(int)), myObject, SLOT(dataReceived()) ); The optional parent argument can be set to make the socket notifier a child of any QObject, e.g. a widget. This will ensure that it is automatically destroyed when the widget is destroyed. For read notifiers it makes little sense to connect the activated() signal to more than one slot because the data can be read from the socket only once. Also observe that if you do not read all the available data when the read notifier fires, it fires again and again. If you disable the read notifier your program may deadlock. (The same applies to exception notifiers if you must use them, for instance if you must use TCP urgent data.) For write notifiers, immediately disable the notifier after the activated() signal has been received and you have sent the data to be written on the socket. When you have more data to be written, enable it again to get a new activated() signal. The exception is if the socket data writing operation (send() or equivalent) fails with a "would block" error, which means that some buffer is full and you must wait before sending more data. In that case you do not need to disable and re-enable the write notifier; it will fire again as soon as the system allows more data to be sent. The behavior of a write notifier that is left in enabled state after having emitting the first activated() signal (and no "would block" error has occurred) is undefined. Depending on the operating system, it may fire on every pass of the event loop or not at all. If you need a time-out for your sockets you can use either timer events or the QTimer class. Socket action is detected in the main event loop of Qt. The X11 version of Qt has a single UNIX select() call that incorporates all socket notifiers and the X socket. Note that on XFree86 for OS/2, select() works only in the thread in which main() is running; you should therefore use that thread for GUI operations. See also QSocket, QServerSocket, QSocketDevice, and Input/Output and Networking. Member Type Documentation QSocketNotifier::Type QSocketNotifier::Read QSocketNotifier::Write QSocketNotifier::Exception MEMBER FUNCTION DOCUMENTATION
QSocketNotifier::QSocketNotifier ( int socket, Type type, QObject * parent = 0, const char * name = 0 ) Constructs a socket notifier called name, with the parent, parent. It watches socket for type events, and enables it. It is generally advisable to explicitly enable or disable the socket notifier, especially for write notifiers. See also setEnabled() and isEnabled(). QSocketNotifier::~QSocketNotifier () Destroys the socket notifier. void QSocketNotifier::activated ( int socket ) [signal] This signal is emitted under certain conditions specified by the notifier type(): <ol type=1> QSocketNotifier::Read - There is data to be read (socket read event). QSocketNotifier::Write - Data can be written (socket write event). QSocketNofifier::Exception - An exception has occurred (socket exception event). The socket argument is the socket identifier. See also type() and socket(). bool QSocketNotifier::isEnabled () const Returns TRUE if the notifier is enabled; otherwise returns FALSE. See also setEnabled(). void QSocketNotifier::setEnabled ( bool enable ) [virtual] Enables the notifier if enable is TRUE or disables it if enable is FALSE. The notifier is enabled by default. If the notifier is enabled, it emits the activated() signal whenever a socket event corresponding to its type occurs. If it is disabled, it ignores socket events (the same effect as not creating the socket notifier). Write notifiers should normally be disabled immediately after the activated() signal has been emitted; see discussion of write notifiers in the class description above. See also isEnabled() and activated(). int QSocketNotifier::socket () const Returns the socket identifier specified to the constructor. See also type(). Type QSocketNotifier::type () const Returns the socket event type specified to the constructor: QSocketNotifier::Read, QSocketNotifier::Write, or QSocketNotifier::Exception. See also socket(). SEE ALSO
http://doc.trolltech.com/qsocketnotifier.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qsocketnotifier.3qt) and the Qt version (3.1.1). Trolltech AS 9 December 2002 QSocketNotifier(3qt)
All times are GMT -4. The time now is 11:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy