www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Raw socket TCP/IP

reply Eyyub <eyyub.pangearaion gmail.com> writes:
Hi,

I'm trying to use a raw socket, but when I create a
socket(AddressFamily.INET, SocketType.RAW, ProtocolType.TCP) and then
I use socket.sendTo(datagram, addr) I've got a 10002 code error
"Invalid argument"...

Can anyone help me please, and sorry for my bad english :s
Feb 04 2012
next sibling parent reply David Nadlinger <see klickverbot.at> writes:
On 2/4/12 11:42 PM, Eyyub wrote:
 I'm trying to use a raw socket, […]

Use SocketType.STREAM if you want TCP. SOCK_RAW is for cases where you want a raw IP socket (for the exact details, look it up in your OS docs). David
Feb 04 2012
next sibling parent reply "Eyyub" <eyyub.pangearaion gmail.com> writes:
 Use SocketType.STREAM if you want TCP. SOCK_RAW is for cases 
 where you want a raw IP socket

Yes, I want a raw IP socket, but when I sendTo my datagram(ip and tcp headers) with a raw IP socket, Wireshark say that my datagram is IPv4 type protocol:unknow(255)... In C or C++ programming language, ID_HDRINCL with setsockopt indicates the application provides the IP header but in D' there isn't this option :/ . Thanx Eyyub,(sorry for ma bad english)
Feb 05 2012
parent dennis luehring <dl.soluz gmx.net> writes:
Am 08.02.2012 19:35, schrieb Eyyub:
 BUMP,

 I really need help please !


 Eyyub.

what are you trying to archive? did you got an Ethernet-Frame+IP-Frame+(your replacement for tcp or udp) - or are your trying to change the tcp frame before sending? and if your using Windows: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740548%28v=vs.85%29.aspx ---- here are two basic types of such raw sockets: The first type uses a known protocol type written in the IP header that is recognized by a Winsock service provider. An example of the first type of socket is a socket for the ICMP protocol (IP protocol type = 1) or the ICMPv6 protocol (IP procotol type = 58). The second type allows any protocol type to be specified. An example of the second type would be an experimental protocol that is not directly supported by the Winsock service provider such as the Stream Control Transmission Protocol (SCTP). ---- Limitations on Raw Sockets On Windows 7, Windows Vista, Windows XP with Service Pack 2 (SP2), and Windows XP with Service Pack 3 (SP3), the ability to send traffic over raw sockets has been restricted in several ways: -TCP data cannot be sent over raw sockets. -UDP datagrams with an invalid source address cannot be sent over raw sockets. The IP source address for any outgoing UDP datagram must exist on a network interface or the datagram is dropped. This change was made to limit the ability of malicious code to create distributed denial-of-service attacks and limits the ability to send spoofed packets (TCP/IP packets with a forged source IP address). These above restrictions do not apply to Windows Server 2008 R2, Windows Server 2008 , Windows Server 2003, or to versions of the operating system earlier than Windows XP with SP2.
Mar 07 2012
prev sibling next sibling parent "Eyyub" <eyyub.pangearaion gmail.com> writes:
If the source code can help : 
http://paste.pocoo.org/show/OJK11zDw6jAaurlKLT3Z/ .

Eyyub,
Feb 05 2012
prev sibling next sibling parent "Eyyub" <eyyub.pangearaion gmail.com> writes:
BUMP,

I really need help please !


Eyyub.
Feb 08 2012
prev sibling next sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--047d7b10cef576587b04baa67100
Content-Type: text/plain; charset=ISO-8859-1

this might be a little late but could it be that the ethernet header was
also needed?

--047d7b10cef576587b04baa67100
Content-Type: text/html; charset=ISO-8859-1

this might be a little late but could it be that the ethernet header was also
needed?

--047d7b10cef576587b04baa67100--
Mar 07 2012
prev sibling parent "Tyler Jameson Little" <beatgammit gmail.com> writes:
Just curious, but what exactly do you need a raw IP socket for?
Mar 07 2012
prev sibling next sibling parent "Gangadhar" <gangadhar.509 gmail.com> writes:
By using raw s ocket programing data transfer from client to 
server please help me about this,any one have source code send me 
.........
Aug 01 2012
prev sibling next sibling parent "Regan Heath" <regan netmail.co.nz> writes:
On Wed, 01 Aug 2012 11:00:54 +0100, Gangadhar <gangadhar.509 gmail.com>  
wrote:

 By using raw s ocket programing data transfer from client to server  
 please help me about this,any one have source code send me .........

The phobos source contains socket code you can inspect .. perhaps not RAW sockets but I suspect you mean low-level STREAM or UDP and not actually RAW sockets (correct me if I'm wrong). Otherwise, there is always google. You do sockets programming in D, exactly as you would in C/C++ all you need is a .d file describing the C socket API (structures, and function signatures) and then you compile and link to ws2_32.lib (on windows). R -- Using Opera's revolutionary email client: http://www.opera.com/mail/
Aug 01 2012
prev sibling parent 1100110 <10equals2 gmail.com> writes:
On Wed, 01 Aug 2012 05:36:07 -0500, Regan Heath <regan netmail.co.nz>  
wrote:

 On Wed, 01 Aug 2012 11:00:54 +0100, Gangadhar <gangadhar.509 gmail.com>  
 wrote:

 By using raw s ocket programing data transfer from client to server  
 please help me about this,any one have source code send me .........

The phobos source contains socket code you can inspect .. perhaps not RAW sockets but I suspect you mean low-level STREAM or UDP and not actually RAW sockets (correct me if I'm wrong). Otherwise, there is always google. You do sockets programming in D, exactly as you would in C/C++ all you need is a .d file describing the C socket API (structures, and function signatures) and then you compile and link to ws2_32.lib (on windows). R

Check out vibe. http://vibed.org/ They have a raw tcp class you can use. http://vibed.org/api/vibe.core.tcp#TcpConnection -- Using Opera's revolutionary email client: http://www.opera.com/mail/
Aug 18 2012