A method for optimizing the use of gateways (GW1,GW2,GW3) based on a category of message to be sent by a connected object (IoT1), said connected object (loT1) being able to access several gateways (GW1,GW2,GW3) suitable for transmitting a message sent by the connected object, said optimization method being characterized in that: - a procedure of discovery, by the connected object (IoT1), of available gateways for the connected object, said procedure of discovery comprising: ∘ broadcasting by the connected object (IoT1) a query message (BCM) in a plurality of data transport subnets , and ∘ receiving by the connected object response messages sent by each of the available gateways in response to the query message (BCM), said response messages containing gateway connectivity parameters and a value of the validity time of said connectivity parameters; - a procedure of attributing priority levels (P1.1, P1.2,P2.1, P2.2) to the available gateways (GW1,GW2) by category of message to be sent, said procedure for attributing priority levels comprising the execution by the connected object of at least one prioritization function, in order to calculate priority levels for each gateway from connectivity parameters and based on the category of message to be sent; and - a procedure of classifying by the connected object the available gateways by order of their respective priority levels based on the category of message to be sent, with a view to choosing one of said available gateways for sending data messages; and in that the priority levels (P1.1,P1.2,P2.1,P2.2) of the available gateways (GW1,GW2) by category of message are transmitted by the connected object to other connected objects. - a procedure of discovery, by the connected object (IoT1), of available gateways for the connected object, said procedure of discovery comprising: ∘ broadcasting by the connected object (IoT1) a query message (BCM) in a plurality of data transport subnets , and ∘ receiving by the connected object response messages sent by each of the available gateways in response to the query message (BCM), said response messages containing gateway connectivity parameters and a value of the validity time of said connectivity parameters; ∘ broadcasting by the connected object (IoT1) a query message (BCM) in a plurality of data transport subnets , and ∘ receiving by the connected object response messages sent by each of the available gateways in response to the query message (BCM), said response messages containing gateway connectivity parameters and a value of the validity time of said connectivity parameters; - a procedure of attributing priority levels (P1.1, P1.2,P2.1, P2.2) to the available gateways (GW1,GW2) by category of message to be sent, said procedure for attributing priority levels comprising the execution by the connected object of at least one prioritization function, in order to calculate priority levels for each gateway from connectivity parameters and based on the category of message to be sent; and - a procedure of classifying by the connected object the available gateways by order of their respective priority levels based on the category of message to be sent, with a view to choosing one of said available gateways for sending data messages; <EOS>