Can we pass the captured packets as argument to Socket send() function
Question: I'm beginner to Networking. We have sender and receiver application. I have
captured the packets sent by sender to receiver using WinDump.

I'm writing a python sender application which will fuzz the packets sent by
sender to receiver.

I just want to confirm, can I directly put the packet data obtained using
WinDump to socket send() method.

Say, "arp who-has host1 tell host2" is the packet obtained by WinDump

Can I write,

    
    
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((TCP_IP, TCP_PORT))
    s.send(arp who-has host1 tell host2)
    


Answer: In general pyhton network programming you can not pass as the arguments using
send method.you just only pass the string as arguments as variable.

Basically we are using the send() and sendall() method to transmits the TCP
messages.

I have mentioned the below desciption for both the method.

**socket send() method :**

The socket's `send()` method is not guaranteed to send all of the data you
pass it. Instead, it returns the number of bytes that were actually sent and
expects your application to handle retransmission of the unsent portion

    
    
    from socket import socket
    
    sock = socket()
    sock.connect(('1.2.3.4', 1234))
    sock.send('My Name is Dasadiya Chaitanya !!!\n'')
    sock.close()
    

**socket sendall() method :**

which is same work as the `send()` method but python provides a convenience
method called `sendall()` that makes sure all of your data is sent before
returning and also provide the guarantee to send all the data to the receiver.

    
    
    from socket import socket
    
    sock = socket()
    sock.connect(('1.2.3.4', 1234))
    sock.sendall('My Name is Dasadiya Chaitanya !!!\n')
    sock.close()
    

I hope this should helpful for you :)

