~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/internet/iocpreactor/iocpsupport/wsasend.pxi

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2008 Twisted Matrix Laboratories.
 
2
# See LICENSE for details.
 
3
 
 
4
 
 
5
def send(long s, object buff, object obj, unsigned long flags = 0):
 
6
    cdef int rc
 
7
    cdef myOVERLAPPED *ov
 
8
    cdef WSABUF ws_buf
 
9
    cdef unsigned long bytes
 
10
 
 
11
    PyObject_AsReadBuffer(buff, <void **>&ws_buf.buf, <int *>&ws_buf.len)
 
12
 
 
13
    ov = makeOV()
 
14
    if obj is not None:
 
15
        ov.obj = <PyObject *>obj
 
16
 
 
17
    rc = WSASend(s, &ws_buf, 1, &bytes, flags, <OVERLAPPED *>ov, NULL)
 
18
 
 
19
    if rc == SOCKET_ERROR:
 
20
        rc = WSAGetLastError()
 
21
        if rc != ERROR_IO_PENDING:
 
22
            return rc, bytes
 
23
 
 
24
    Py_XINCREF(obj)
 
25
    return rc, bytes
 
26
 
 
27